我正在使用YouTubePlayerSuportFragment加载视频。它不会播放当前视频ID,而是播放以前ID中的视频。每当我从Android应用程序的设置中清除数据时,YouTubePlayer会播放当前的视频ID。如何忽略或跳过YouTubePlayer上的缓存?
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();
}
}
});
答案 0 :(得分:0)
如果您有缓存机制,请检查您的代码。如果你有缓存启用它可能是一个问题。我删除了我的缓存机制,它的工作原理。