Commit 267671dc authored by Geoffrey Métais's avatar Geoffrey Métais

Let PlaybackService to handle seek on media load

parent 0d3b889a
......@@ -2000,13 +2000,18 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
}
@MainThread
public void seek(long position, long length) {
if (length > 0)
setPosition(position/length);
public void seek(long position, double length) {
if (length > 0.0D)
setPosition((float) (position/length));
else
setTime(position);
}
@MainThread
public void saveTimeToSeek(long time) {
mSavedTime = time;
}
@MainThread
public void setPosition(float pos) {
if (mSeekable)
......
......@@ -2504,7 +2504,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
seek(position, mService.getLength());
}
private void seek(long position, float length) {
private void seek(long position, long length) {
mForcedTime = position;
mLastTime = mService.getTime();
mService.seek(position, length);
......@@ -2977,25 +2977,20 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
media.addFlags(MediaWrapper.MEDIA_VIDEO);
boolean seek = true;
if (savedTime <= 0 && media != null && media.getTime() > 0l)
savedTime = media.getTime();
if (savedTime > 0L && !mService.isPlaying())
mService.saveTimeToSeek(savedTime);
// Handle playback
if (!hasMedia)
mService.load(media);
else if (!mService.isPlaying())
mService.playIndex(positionInPlaylist);
else {
seek = false;
onPlaying();
}
if (seek) {
// Set time
if (savedTime <= 0 && media != null && media.getTime() > 0l)
savedTime = media.getTime();
if (savedTime > 0)
seek(savedTime);
}
// Get possible subtitles
getSubtitles();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment