意图播放YouTube播放列表播放列表、意图、YouTube

2023-09-07 16:15:47 作者:狸猫换娘子だ

我想从我的应用程序启动的YouTube播放列表。

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.

推荐答案

要使用YouTube功能在您的应用程序的最佳方法是使用的为Android YouTube的API。你可以了解如何使用的YouTube API 从文档和示例应用程序。

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.

如果您使用的YouTube API ,开始播放列表,你必须这样做你的活动:

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.