What is the best way to auto play YouTube videos on Glass?

264 Views Asked by At

I need a way to automatically play a YouTube video on my Google Glass. I tried the Youtube JS API but after .playVideo() the video doesn't play, it only shows a black screen. I tried embed the video with the autoplay function but it doesn't autoplay. I can play embedded videos only when I click the play button myself.

Is there a simple way to (auto)play a youtube video full screen?

1

There are 1 best solutions below

1
Simon Marquis On BEST ANSWER

If you want to have full control over the video player, you can use the YouTube Android Player API.
You can find more info here.

You'll have to:

  • Download the API client library
  • Register your application through the Google APIs console
  • Setup the library and integrate the YoutubePlayer in your Activity

Take a look at the demo, and especially at the FullscreenDemoActivity.

Edit: A simpler method would be to use this Intent:

Intent i = new Intent();
i.setAction("com.google.glass.action.VIDEOPLAYER");
i.putExtra("video_url", "https://m.youtube.com/watch?v=xxxxxxx"); 
startActivity(i);