Closed
Description
I have several qualities of streams (http). Can i start laod new stream and start play in position where current playing.
How i try to do it:
public void changeQuality(String uri) {
this.oldPosition = exoPlayer.getCurrentPosition();
this.oldState = exoPlayer.getPlayWhenReady();
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context,
userAgent, null);
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource videoSource = new ExtractorMediaSource(Uri.parse(uri),
dataSourceFactory, extractorsFactory, null, null);
exoPlayer.prepare(videoSource);
}
And on onPlayerStateChanged i seek to old position:
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_READY) {
if (this.oldPosition > -1) {
exoPlayer.seekTo(this.oldPosition);
this.oldPosition = -1;
exoPlayer.setPlayWhenReady(this.oldState);
}
}
}
}
But it show first frame than jump to old position. How i can don't show first frame and start showing from old position?