Android TV嵌入式YouTube 1080p [英] Android TV embedded youtube 1080p

查看:146
本文介绍了Android TV嵌入式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播放器完整API在Android TV上不可用,但开发人员目前可以按以下方式使用YouTube意图.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆