到目前为止,这是我的代码:
public class MainActivity extends ActionBarActivity implements
YouTubePlayer.OnInitializedListener {
static private final String DEVELOPER_KEY = "USER API KEY";
static private String VIDEO = "LIuk1qu0RlU";
private YouTubePlayerFragment youTubePlayerFragment;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
youTubePlayerFragment = (YouTubePlayerFragment) getFragmentManager()
.findFragmentById(R.id.youtubeplayerfragment);
youTubePlayerFragment.initialize(DEVELOPER_KEY, this);
}
@Override
public void onInitializationFailure(Provider provider,
YouTubeInitializationResult result) {
if (result.isUserRecoverableError()) {
result.getErrorDialog(this, 0).show();
} else {
Toast.makeText(
this,
"YouTubePlayer.onInitializationFailure(): "
+ result.toString(), Toast.LENGTH_LONG).show();
}
}
@Override
public void onInitializationSuccess(Provider provider,
YouTubePlayer player, boolean wasRestored) {
Toast.makeText(getApplicationContext(),
"YouTubePlayer.onInitializationSuccess()", Toast.LENGTH_LONG)
.show();
player.cueVideo(VIDEO);
}
}
(录制的视频正在播放,但实时视频正在停止我的应用)
我已经尝试video id = all recorded videos
它的工作正常......
当我尝试videoid =LIuk1qu0RlU
它不能正常工作,我还尝试了其他实时视频ID