Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play YouTube video in WebView on Google Glass

Tags:

google-gdk

I have code like this:

setContentView(R.layout.webview);       
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://www.youtube.com/watch?v=_Z5-P9v3F8w");

It'll show the youtube video with the Play button, but none of the Glass gesture can make the video play. Any ideas? Thanks!

like image 830
Jeff Tang Avatar asked Feb 10 '14 00:02

Jeff Tang


People also ask

Can you watch videos on Google Glass?

To view the video in your timeline, swipe forward on the touchpad from the Home screen. Glass will make a collage out of pictures, videos, and vignettes taken during a day and bundle them together. Tap into the bundle to browse and then on a video to play the video.

Is Google Glass still available?

Just two years after they were launched, Google announced they would no longer be producing a consumer version of the glasses.

What can you do with Google Glass for enterprise?

Glass Enterprise can connect you with coworkers in an instant, bringing expertise to right where you are. Invite others to “see what you see” through a live video stream so you can collaborate and troubleshoot in real-time.


1 Answers

Finally figured out how to play Youtube video on Glass!

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

Using WebView can't play the video, using VideoView can only play local MP4 or streaming MP4 (there's some way to hack the MP4 link for a Youtube video, but not reliable). Also, using VideoView can only pause/play the video, but not fast forward or backward. Using the com.google.glass.action.VIDEOPLAYER above solves all the problems WebView and VideoView have.

like image 60
Jeff Tang Avatar answered Oct 19 '22 16:10

Jeff Tang