我上周问了一个关于如何从 Android YouTube 应用循环播放 YouTube 视频的问题。得到的答复是不可行。
我想到了一种解决方法,可以启动一个 YouTube 播放列表,其中包含许多我想要循环播放的视频条目。我发现this类似的问题,但它仅在浏览器中播放时有效。我需要从 YouTube 应用播放播放列表。有谁知道是否可以使用意图启动 YouTube 应用来播放播放列表?
谢谢。
启动 YouTube 应用程序:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=cxLG2wtE7TM")));
您希望启动播放列表的 URL 是:
http://www.youtube.com/watch?v=first-video-id&list=playlist-id&feature=plpp_play_all
我还没有测试过这个。在您的应用程序中尝试一下,看看它是否适合您。
做了更多研究后,我找到了如何在 YouTube 应用程序中打开播放列表
Uri uri = Uri.parse("http://www.youtube.com/playlist?list=" + playlist_id);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(uri);
i.setClassName("com.google.android.youtube", "com.google.android.youtube.app.froyo.phone.PlaylistActivity");
startActivity(i);
我仍然不太确定如何自动开始播放第一个视频...
这个应用程序会为你做到这一点!...但如果有一个默认值那就太好了!
http://www.wowtechy.com/youtube-playlists-continuous-repeat-background-playback-video-cache-android/
我找到了一种通过使用带有 ACTION_VIEW 意图的 URI 的意图来启动播放列表的方法:
http://www.youtube.com/playlist?list=playlist&playnext=1
Intent intent = createPlayPlaylistIntent(currentContext, playlistId);
startActivity(intent);