我需要在Amazon Fine TV中实现播放Youtube视频。 我决定使用https://developers.google.com/youtube/android/player/。 我的活动是:
EXEC @ReturnValue = sp_addPermissions @sSQL, @column
activity_youtube.xml
package com.ticketmaster.amazon.activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import com.google.android.youtube.player.YouTubeBaseActivity;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayerView;
import com.ticketmaster.amazon.R;
import com.ticketmaster.api.helper.PropertiesHelper;
/**
* Created by Georgii on 4/26/2016.
*/
public class PlaybackYoutubeActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {
private static final int RECOVERY_REQUEST = 1;
public static final String YOUTUBE_KEY = "-----MYKEY----------";
private YouTubePlayerView youTubeView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_youtube);
youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);
PropertiesHelper.loadProperties(this);
youTubeView.initialize(YOUTUBE_KEY, this);
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player, boolean wasRestored) {
if (!wasRestored) {
player.cueVideo("fhWaJi1Hsfo"); // Plays https://www.youtube.com/watch?v=fhWaJi1Hsfo
}
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult errorReason) {
if (errorReason.isUserRecoverableError()) {
errorReason.getErrorDialog(this, RECOVERY_REQUEST).show();
} else {
String errMsg = getString(R.string.video_error_unknown_error);
Toast.makeText(this, errMsg, Toast.LENGTH_LONG).show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RECOVERY_REQUEST) {
// Retry initialization if user performed a recovery action
getYouTubePlayerProvider().initialize(YOUTUBE_KEY, this);
}
}
protected YouTubePlayer.Provider getYouTubePlayerProvider() {
return youTubeView;
}
}
当我运行对话框epeares并单击按钮" GET YOUTUBE BUTTON"得不到任何结果。回调 onInitializationFailure 中的值 YouTubeInitializationResult errorReason 为 SERVICE_MISSING 。 Youtube App已安装在亚马逊Fire TV中。
有人知道如何在Amazon Fire TV中运行Youtube视频吗?
答案 0 :(得分:3)
我遇到了同样的问题。
经过一些研究,我找到了可能的答案here
Levon @ Amazon写道,Youtube视频播放器API是Google API的一部分,而不是Android API,所以这就是为什么不工作的原因。
可能的解决方案可能是:
希望这有帮助