2012-06-20 19 views
0

即時通訊試圖在Android應用程序的VideoView中播放視頻。 問題是我如何從youtube獲取正確的鏈接,而不僅僅是網頁?如何獲取正確的URL到視頻

setContentView(R.layout.videopopup); 
VideoView vv = (VideoView)findViewById(R.id.videoElem); 

MediaController mc = new MediaController(this); 
mc.setEnabled(true); 
mc.show(0); 
vv.setMediaController(mc); 
vv.setVideoURI(Uri.parse("http://www.youtube.com/v/oFL2rszPmmU?version=3&feature=player_detailpage")); 
vv.requestFocus(); 
vv.showContextMenu(); 
vv.start(); 
在這個環節

Video View not playing youtube video

葉夫根Nacu解釋了哪些鏈接是應該的,但不知道如何從給定的YouTube頁面檢索它。

+0

檢查此鏈接http://keyeslabs.com/joomla/blogs/i-think-im-becoming-an-android/ 51-polish-your-app-free-embeddable-android-youtube-activity – vrs

+0

https://developers.google.com/youtube/2.0/developers_guide_protocol_audience – vrs

回答

0

簡單的方式使用默認的YouTube應用播放視頻:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(your youtube url); 

YouTube應用做的一切。你不需要做任何事情。

,如果不解決,使用web視圖,而不是videoview在你的代碼