How to play YouTube video in WebView on Google Glass

回眸只為那壹抹淺笑 提交于 2019-12-09 06:28:55

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/21666896/how-to-play-youtube-video-in-webview-on-google-glass

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!