我正在YouTubePlayerSupportFragment
中实施RecyclerView.ViewHolder
,视频正在从firebase加载。收费方式为setUrlVideo()
。
public void setUrlVideo(final String URLvideo, final Context context)
{
FrameLayout field = (FrameLayout) mView.findViewById(R.id.youtube_fragment);
if(!"WithOutVideo".equals(URLvideo)){ //If is diferent
YouTubePlayerSupportFragment youTubePlayerFragment = YouTubePlayerSupportFragment.newInstance();
youTubePlayerFragment.initialize("AIzaSyCCySPG-sCKd17cHrWiZ5pJjZ-a7JoS6xo",
new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
YouTubePlayer youTubePlayer, boolean b) {
if (!b) {
YPlayer = youTubePlayer;
//YPlayer.setFullscreen(true);
YPlayer.cueVideo(URLvideo);
//YPlayer.play();
}
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider,
YouTubeInitializationResult youTubeInitializationResult) {
String error = youTubeInitializationResult.toString();
Toast.makeText(context, R.string.failYoutube, Toast.LENGTH_LONG).show();
}
});
FragmentTransaction transaction = ((MainActivity)context).getSupportFragmentManager().beginTransaction();
transaction.add(field, youTubePlayerFragment).commit();
}
}
错误如下:
Error:(88, 24) error: no suitable method found for add(FrameLayout,YouTubePlayerSupportFragment)
method FragmentTransaction.add(Fragment,String) is not applicable
(argument mismatch; FrameLayout cannot be converted to Fragment)
method FragmentTransaction.add(int,Fragment) is not applicable
(argument mismatch; FrameLayout cannot be converted to int)