Detecting When A Youtube Video Finishes In Android
I´m making in app in android using youtube api. The app shows a youtube video and then I want to do a question about the video after the user watches it. I would like to know who
Solution 1:
You can get a callback when video has completed if you are using the youtube API. So by ovveriding the following you can implement your code,
@OverridepublicvoidonVideoEnded() {
//Put your code here
}
Solution 2:
Actually we need to implement our activity/fragment with YouTubePlayer.PlayerStateChangeListener
Then we shall get the @Override method of onVideoEnded() as with some other methods like:
@Override
public void onLoading() {
}
@Override
public void onLoaded(String s) {
}
@Override
public void onAdStarted() {
}
@Override
public void onVideoStarted() {
}
@Override
public void onVideoEnded() {
//Put your code here
}
@Override
public void onError(YouTubePlayer.ErrorReason errorReason) {
}
Post a Comment for "Detecting When A Youtube Video Finishes In Android"