Android TV 内嵌 youtube 1080p [英] Android TV embedded youtube 1080p
问题描述
我想在我的 Android TV 应用程序上显示一些 YouTube 视频,我试图移植我已经在手机上使用的东西,但我在那里使用了 YouTube Android API 播放器,它似乎在 Android TV 上不起作用.
I want to display some YouTube videos on my Android TV application, I was trying to port something I already have working on a phone, but there I use the YouTube Android API player, that doesn't seem to work on Android TV.
我发现了这个 https://code.google.com/p/gdata-issues/issues/detail?id=6998 所以看起来我并不孤单.
I found this https://code.google.com/p/gdata-issues/issues/detail?id=6998 so it looks like I'm not alone.
我添加了一个 WebView,可以显示视频,但无法获得全高清分辨率,嵌入视频可以吗?
I added a WebView and I can display a video but I can't get full hd resolution, is that possible with embedded videos?
推荐答案
YouTube Player Full API 在 Android TV 上不可用,但开发者目前可以按如下方式使用 YouTube Intent.
YouTube Player Full API is not available on Android TV but developers can currently use the YouTube intent as follows.
String videoId = "dQw4w9WgXcQ";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + videoId));
intent.putExtra("force_fullscreen", true);
intent.putExtra("finish_on_ended", true);
startActivity(intent);
这将使用 YouTube 应用播放视频.force_fullscreen=true 移除相关视频的导航,而 finish_on_ended=true 在视频播放完毕后返回调用应用.
This will use YouTube app to play videos. The force_fullscreen=true removes navigation to related videos while the finish_on_ended=true returns to calling app when video is done.
你也可以使用
Intent intent = YouTubeIntents.createPlayVideoIntentWithOptions(this, videoId, true, false);
如果您下载了 YouTubeAndroidPlayerAPI:
if you download the YouTubeAndroidPlayerAPI:
https://developers.google.com/youtube/android/player/downloads/
并在您的项目中包含 jar 文件
and include the jar file in your project
这篇关于Android TV 内嵌 youtube 1080p的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!