我正在尝试创建一个Android应用程序,该应用程序一旦在youtube上搜索了视频,便会同时在两个YoutubePlayerViews
中播放,这是PlayerActivity
的代码
public abstract class PlayerActivity extends YouTubeBaseActivity implements OnInitializedListener {
private YouTubePlayerView playerView, playerView1;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_player);
playerView = (YouTubePlayerView)findViewById(R.id.player_view);
playerView1 = (YouTubePlayerView)findViewById(R.id.player_view1);
playerView.initialize(YoutubeConnector.KEY, new YouTubePlayer.OnInitializedListener(){
@Override
public void onInitializationFailure(Provider provider,
YouTubeInitializationResult result) {
Toast.makeText(getApplicationContext(), getString(R.string.failed), Toast.LENGTH_LONG).show();
}
@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player,
boolean restored) {
if (!restored) {
player.cueVideo(getIntent().getStringExtra("VIDEO_ID"));
}
}
});
playerView1.initialize(YoutubeConnector.KEY, new OnInitializedListener() {
@Override
public void onInitializationFailure(Provider provider,
YouTubeInitializationResult result) {
Toast.makeText(getApplicationContext(), getString(R.string.failed), Toast.LENGTH_LONG).show();
}
@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player,
boolean restored) {
if (!restored) {
player.cueVideo(getIntent().getStringExtra("VIDEO_ID"));
}
}
});
TextView video_title = (TextView)findViewById(R.id.player_title);
TextView video_desc = (TextView)findViewById(R.id.player_description);
TextView video_id = (TextView)findViewById(R.id.player_id);
video_title.setText(getIntent().getStringExtra("VIDEO_TITLE"));
video_id.setText("Video ID : "+(getIntent().getStringExtra("VIDEO_ID")));
video_desc.setText(getIntent().getStringExtra("VIDEO_DESC"));
}
}
问题是,一个视频加载时,另一视频仍保留在黑屏上,此API允许同时进行riproduction?