Commit 0d3b889a authored by Geoffrey Métais's avatar Geoffrey Métais

seek methods for playbackService

Handle setPosition, then setTime if length is not available.
parent 5a9aab57
......@@ -1110,7 +1110,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
@Override
public void onSeekTo(long pos) {
setTime(pos);
seek(pos);
}
@Override
......@@ -1342,7 +1342,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
// load playlist
loadLocations(mediaPathList, position);
if (time > 0)
setTime(time);
seek(time);
if(!audio) {
boolean paused = mSettings.getBoolean(PreferencesActivity.VIDEO_PAUSED, !isPlaying());
float rate = mSettings.getFloat(PreferencesActivity.VIDEO_SPEED, getRate());
......@@ -1741,7 +1741,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
mMediaPlayer.setEventListener(mMediaPlayerListener);
mMediaPlayer.play();
if(mSavedTime != 0l)
mMediaPlayer.setTime(mSavedTime);
seek(mSavedTime);
mSavedTime = 0l;
determinePrevAndNextIndices();
......@@ -1994,6 +1994,19 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
return mMediaPlayer.setVolume(volume);
}
@MainThread
public void seek(long position) {
seek(position, getLength());
}
@MainThread
public void seek(long position, long length) {
if (length > 0)
setPosition(position/length);
else
setTime(position);
}
@MainThread
public void setPosition(float pos) {
if (mSeekable)
......
......@@ -2507,10 +2507,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private void seek(long position, float length) {
mForcedTime = position;
mLastTime = mService.getTime();
if (length <= 0f)
mService.setTime(position);
else
mService.setPosition(position / length);
mService.seek(position, length);
}
private void seekDelta(int delta) {
......
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