我在我的应用中使用了YouTubePlayerAPI和YouTubePlayerSupportFragment。最近,我发现当从辅助页面支持时,YouTubePlayer会继续在第一页上加载。但我无法找出导致它的原因。我一直在寻找信息,但我找不到任何有用的信息。
我的测试方法:
单击TextView以启动辅助页面。回去,问题出现了。
这是我的代码:
public class FragmentDemoActivity extends Activity implements YouTubePlayer.OnInitializedListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragments_demo);
TextView tvDes = (TextView) findViewById(R.id.tv_start_another);
tvDes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(v.getContext(), FragmentDemoActivity.class));
}
});
YouTubePlayerFragmentWrap youTubePlayerFragment =
(YouTubePlayerFragmentWrap) getFragmentManager().findFragmentById(R.id.youtube_fragment);
youTubePlayerFragment.initialize(DeveloperKey.DEVELOPER_KEY, this);
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player, boolean wasRestored) {
if (!wasRestored) {
player.cueVideo("nCgQDjiotG0");
}
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
}
}