Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Android JWPlayerView seek() when paused


Hi, concerning the JWPlayerView on Android:
Programmatically seeking to a position with seek(Long position) seems to only work when the video is playing, not when the video is paused.
When the video is paused and I want to seek to a position, I have to add an OnPlayListener, then play, then seek when the video is playing, add an OnSeekedListener, then pause again when seeking is done. Very cumbersome.

Should (programmatically) seeking when paused work? Will this be fixed? Do you have a better alternative to my approach?

Best, Florian

1 Community Answers

George

JW Player Support Agent  
0 rated :

Hello Florian,

You can most definitely seek from a Paused state but after the seek is done you will enter a Playing state, that is the intended behavior of the player.

From what you described you are trying to seek from a Paused State and remain in a paused state, and yes it does take a few extra lines of code to get it to work like that and there is a small bug with the behavior of onSeeked() in our current version that we’ll have to patch.

Here’s some code on how I handled the case:
boolean isDiscreetSeek = false;
@Override
public void onPause(PlayerState oldState) {
isDiscreetSeek=true;
}

@Override
public void onPlay(PlayerState oldState) {
isDiscreetSeek=false;
}

@Override
public void onSeek(int position, int offset) {
if(isDiscreetSeek){
mPlayerView.pause(true);
}
}

@Override
public void onSeeked() {
if(isDiscreetSeek){
mPlayerView.pause(true);
}
}

If onSeeked fired as it was designed I would not have to pause twice, but currently this is a workaround until the bug is fixed

This question has received the maximum number of answers.