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,
@Override
public void onVideoEnded() {
//Put your code here
}
Вопрос
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 can I detect the end of the video in order to start one activity with a question. Thanks in advance.
Решение
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,
@Override
public void onVideoEnded() {
//Put your code here
}
Другие советы
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) {
}