Skip to content

Instantly share code, notes, and snippets.

@animecyc
Last active December 24, 2015 16:29
Show Gist options
  • Save animecyc/6828874 to your computer and use it in GitHub Desktop.
Save animecyc/6828874 to your computer and use it in GitHub Desktop.
HLS Seeking - Android Brightcove SDK
// For reference here are the vars being used
//
// protected final BrightcoveVideoView videoPlayer;
// protected final EventEmitter eventEmitter = new EventEmitterImpl();
// private int shouldSeekTo = 0;
// private boolean correctingPlayPosition = false;
videoPlayer = new BrightcoveVideoView(context) {
@Override
public void seekTo(int msec)
{
if (msec != shouldSeekTo || correctingPlayPosition)
{
if (correctingPlayPosition)
{
msec -= 1000;
if (msec < 0)
{
msec = 0;
}
}
super.seekTo(msec);
}
shouldSeekTo = msec;
}
};
videoPlayer.setEventEmitter(eventEmitter);
eventEmitter.on(EventType.DID_SEEK_TO, new EventListener() {
@Override
public void processEvent(Event event) {
if (shouldSeekTo != videoPlayer.getCurrentPosition())
{
correctingPlayPosition = true;
videoPlayer.seekTo(shouldSeekTo);
}
else
{
correctingPlayPosition = false;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment