0

So, I'm using this code to play some video after a button click:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=VYqhW2YFN7k")));

But it just opens the whole youtube web page in the browser with suggested videos and stuff. Is there a way to directly play the video in landscape mode in fullscreen?

marjanbaz
  • 1,052
  • 3
  • 18
  • 35
  • Take a look at https://developers.google.com/youtube/android/player/ on how to embed YouTube player in your application. –  Jun 26 '13 at 18:32
  • You can try some option right here ->> http://stackoverflow.com/questions/11108441/play-youtube-video-in-full-screen-mode-in-my-android-app – Deimantas Brandišauskas Jun 26 '13 at 18:36

3 Answers3

2

If You are using Youtubeplayer APi to view video than you can use this line in onInitializationSuccess Method

youTubePlayer.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE);
            youTubePlayer.setFullscreen(true);
Maulik Patel
  • 717
  • 1
  • 10
  • 22
1

Set your screen orientation landscape in android manifestfile.

Arut
  • 940
  • 14
  • 32
  • Yes, but my orientation is portrait where my imagebutton is, with which I start the YouTube video. And it can't be landscape, cause of the design. I guess, when I start the video the next activity is web browser. – marjanbaz Jun 26 '13 at 21:38
  • If you set your orientation landscape in manifest file means all design should be landscape mode only. – Arut Jun 27 '13 at 04:12
  • Well, I don't wanna do that. – marjanbaz Jun 27 '13 at 10:37
  • check this this will help "http://stackoverflow.com/questions/9960582/youtube-video-full-screen-mode-switches-activity-ui-into-landscape-mode" – Arut Jun 27 '13 at 13:11
  • 2
    try this also "intent.putExtra("force_fullscreen",true); " – Arut Jun 27 '13 at 13:12
  • I don't know what I get with that "force_fullscreen" that I send with an intent? Nothing, cause I tried. – marjanbaz Jun 27 '13 at 14:35
  • what version you are using. – Arut Jun 27 '13 at 14:42
  • 2
    intent.putExtra("force_fullscreen",true); it work on 4.1 and higher. – Arut Jun 28 '13 at 05:37
0

You can use the new YouTube Data API by Google.

There, you have a lot of control of how to show the video. This includes even putting the view that shows the video into your activity, so you can set whatever orientation you wish for it.

android developer
  • 114,585
  • 152
  • 739
  • 1,270