Nexus的播放器(安卓电视)YouTubeAndroidPlayerApi错误:"初始化YouTube播放器时发生错误" [英] Nexus Player (Android TV) YouTubeAndroidPlayerApi error: "An error occurred when initializing the YouTube player."
问题描述
我使用YouTube的Android播放器API来播放一些YouTube视频。我的code是工作正常的:
I'm using the YouTube android player API to play some youtube videos. My code is working fine on:
三星S3
三星Galaxy Tab III
Samsung Galaxy Tab III
的Nexus 7(与Android 5.1.1)
Nexus 7 (with Android 5.1.1)
不过,这并不在Nexus的球员工作。我得到的错误:
But it doesn't work on the Nexus Player. I get the error:
初始化YouTube播放器时发生错误。
"An error occurred when initializing the YouTube player."
在Nexus的球员我的YouTube应用程序是1.0.5.5版
My Youtube app on the Nexus player is version 1.0.5.5
我无法看到YouTube应用程序已经过时,也没有什么办法来更新它的任何迹象。如果是这样的问题,我将说明如何更新它。
I couldn't see any indications that the youtube app is out of date nor any way to update it. If that is the problem I will instructions on how to update it.
我觉得我的表现就可以了:
I think my manifest is ok:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="coacb.org.examplevideoondemandapp" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".vodActivity" />
<activity
android:name=".youtubePlayer"
android:label="@string/title_activity_youtube_player" >
</activity>
<activity
android:name=".webviewInfo"
android:label="@string/title_activity_webview_info" >
</activity>
</application>
</manifest>
在此先感谢
推荐答案
感谢的建议和意见dextor和ianhanniballake我能得到它的工作好有以下code:
Thanks to the suggestions and comments from dextor and ianhanniballake I was able to get it to work good with the following code:
String videoID = "ARM42-eorzE";//youtube video id
if (getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION)
|| getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)){
Intent youtubeIntent = YouTubeIntents.createPlayVideoIntent(getContext(), videoID);
context.startActivity(youtubeIntent);
} else {
Intent myIntent = new Intent(getContext(), youtubePlayer.class);
myIntent.putExtra("youtubeID",videoID);
context.startActivity(myIntent);
}
这篇关于Nexus的播放器(安卓电视)YouTubeAndroidPlayerApi错误:&QUOT;初始化YouTube播放器时发生错误&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!