我正在使用Youtube Player api在我的应用程序中播放youtube视频.视频在1-2秒后开始播放和暂停
我创建了Video Fragment和ViewGroup.随后我创建了一些youtobe视频.
VideoFragment
public static final class VideoFragment extends YouTubePlayerSupportFragment implements
OnInitializedListener
{
private YouTubePlayer player;
private String videoId;
public static VideoFragment newInstance()
{
return new VideoFragment();
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
initialize(Constants.DEVELOPER_KEY, this);
}
@Override
public void onDestroy()
{
if (player != null)
{
player.release();
}
super.onDestroy();
}
public void setVideoId(String videoId)
{
if (videoId != null && !videoId.equals(this.videoId))
{
this.videoId = videoId;
if (player != null)
{
player.cueVideo(videoId);
}
}
}
public …Run Code Online (Sandbox Code Playgroud)