Intent to play YouTube playlist

自作多情 提交于 2019-12-02 04:27:00

问题


I would like to start YouTube playlist from my application.

For single video this is obvious

startActivity(new Intent(Intent.ACTION_VIEW, 
                         Uri.parse("http://www.youtube.com/watch?v=videoid")));

but I have problem with playlist. When I put link to playlist it always plays only one video from it.


回答1:


Check whether you are passing same url throughout the play list (http://www.youtube.com/watch?v=videoid). check for the value of videoid whether it is same.




回答2:


The best way to use YouTube functionalities in your app is to use YouTube API for Android. You can find out how to use YouTube API from the documentation and the sample app.

If you use YouTube API, to start playlist you have to do this in your Activity:

String PLAYLIST_ID = "UCVHFbqXqoYvEWM1Ddxl0QDg";

//"this" is Context
Intent intent = YouTubeIntents.createPlayPlaylistIntent(this, PLAYLIST_ID);
startActivity(intent);

See the method's documentation here.



来源:https://stackoverflow.com/questions/8489306/intent-to-play-youtube-playlist

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