0

I am beginner in android and developing an app in which i am using YouTubePlayer API in order to show Youtube Videos of specific Playlist. I'm succeed in doing so. But what I want is that whenever the user selects any video from that playlist; the video should be played in Full Screen. Here is my code:

public class Main4Activity extends AppCompatActivity
{
    Toolbar main_toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main4);
        main_toolbar=(Toolbar) findViewById(R.id.my_thirdtoolbar);
        setSupportActionBar(main_toolbar);
        getSupportActionBar().setTitle(R.string.my_tb_title);
        getSupportActionBar().setIcon(R.drawable.tblogo);
        OnClickButtonListener();
    }

    public void OnClickButtonListener()
    {
        Button youtubebtn = (Button) findViewById(R.id.button8);
        youtubebtn.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                String PLAYLIST_ID = "PLXRActLQ03oY_6AQb-5EMuKFYQA_fDE40";
                Intent intent=YouTubeIntents.createOpenPlaylistIntent(Main4Activity.this,PLAYLIST_ID);
                startActivity(intent);

            }
        }
        );
    }
}
reflective_mind
  • 1,475
  • 3
  • 15
  • 28
Iqra
  • 69
  • 1
  • 13

1 Answers1

0

You can use methods from YouTubeIntents. Here are some methods that you can use:

  • canResolvePlayVideoIntentWithOptions (Context context)

    Checks if the YouTube application installed on the user's device supports the fullscreen and finishOnEnd optional parameters when resolving a play video intent.

    • If this method returns true, then your application can call the createPlayVideoIntentWithOptions(Context context, String videoId, boolean fullscreen, boolean finishOnEnd) method which creates an Intent that, when resolved, will start playing the video specified by videoId, within the YouTube application.
    • If this method returns false, then your application should call the createPlayVideoIntent(Context context, String videoId) method instead.

Additionally, please also check other implementations and try the suggested solutions in this SO post. Hope it helps!

Community
  • 1
  • 1
Teyam
  • 7,686
  • 3
  • 15
  • 22
  • I have used createPlayVideoIntent method. and it shows the playlist but i want that when user clicks on any video from that playlist it will be played in full screen – Iqra Oct 19 '16 at 14:51
  • Have you also used `canResolvePlayVideoIntentWithOptions()` method? – Teyam Oct 19 '16 at 15:05
  • I had posted the code above. i have only used one method to show specific playlist videos. – Iqra Oct 19 '16 at 15:08
  • As mentioned in the documentation that I have given, use the `canResolve` methods before sending an intent to make sure that the user's device has a version of the YouTube application that supports the given intent. – Teyam Oct 19 '16 at 15:17