2
YouTubePlayerSuportFragmentを使用して動画を読み込み中です。以前のIDからのビデオを再生するのではなく、現在のビデオIDを再生しません。アンドロイドアプリの設定からデータをクリアするたびに、YouTubePlayerは現在の動画IDを再生します。 YouTubePlayerのキャッシュを無視またはスキップするにはどうすればよいですか?YouTubeプレーヤーは新しいビデオIDで更新した後に前の動画IDを再生します
YouTubePlayerSupportFragment youTubePlayerSupportFragment = YouTubePlayerSupportFragment.newInstance();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.add(R.id.youtube_layout, youTubePlayerSupportFragment).commit();
youTubePlayerSupportFragment.initialize(LinkConfig.API_KEY_ANDROID, new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
youTubePlayer.loadVideo(SplashScreen.mainData.getVod().getCount().getPopular());
youTubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
youTubePlayer.setShowFullscreenButton(true);
youTubePlayer.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION | YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE);
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
if (youTubeInitializationResult.isUserRecoverableError()) {
youTubeInitializationResult.getErrorDialog(getActivity(), 1).show();
} else {
Toast.makeText(getActivity(), "errorMessage", Toast.LENGTH_LONG).show();
}
}
});