Skip to content
Snippets Groups Projects
Commit cd053d55 authored by Ezra Pierce's avatar Ezra Pierce Committed by Sébastien Blin
Browse files

media player: fix seekToTime while player is paused

With the media player paused, calling seekToTime(startTime+100) results in getPlayerPosition() returning a negative value.
This patch adds a check in seekToTime to update the pauseInterval before updating the new startTime to fix this issue.
See MediaPlayerTest::testSeekWhilePaused() for the specific unit test that was failing.

Change-Id: Ib91c2998199728af532ba9dc83ea6ab830852b69
parent bb20b50e
No related branches found
No related tags found
No related merge requests found
......@@ -222,7 +222,14 @@ MediaPlayer::seekToTime(int64_t time)
}
flushMediaBuffers();
demuxer_->updateCurrentState(MediaDemuxer::CurrentState::Demuxing);
startTime_ = av_gettime() - pauseInterval_ - time;
int64_t currentTime = av_gettime();
if (paused_){
pauseInterval_ += currentTime - lastPausedTime_;
lastPausedTime_ = currentTime;
}
startTime_ = currentTime - pauseInterval_ - time;
if (hasAudio()) {
audioInput_->setSeekTime(time);
audioInput_->updateStartTime(startTime_);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment