Skip to content
Snippets Groups Projects
Commit d6cbebae authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Fix wrong initial time when restoring videos

Fixes #1650
parent ed3b67ea
No related branches found
No related tags found
1 merge request!914Fix wrong initial time when restoring videos
Pipeline #74623 passed with stage
in 3 minutes and 32 seconds
......@@ -67,6 +67,7 @@ const val FORCE_PLAY_ALL = "force_play_all"
const val SCREEN_ORIENTATION = "screen_orientation"
const val VIDEO_RESUME_TIME = "VideoResumeTime"
const val VIDEO_RESUME_URI = "VideoResumeUri"
const val ENABLE_SEEK_BUTTONS = "enable_seek_buttons"
const val ENABLE_DOUBLE_TAP_SEEK = "enable_double_tap_seek"
const val ENABLE_VOLUME_GESTURE = "enable_volume_gesture"
......
......@@ -42,10 +42,7 @@ import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.resources.ACTION_REMOTE_PLAYPAUSE
import org.videolan.resources.ACTION_REMOTE_STOP
import org.videolan.resources.ACTION_REMOTE_SWITCH_VIDEO
import org.videolan.tools.POPUP_KEEPSCREEN
import org.videolan.tools.Settings
import org.videolan.tools.VIDEO_RESUME_TIME
import org.videolan.tools.putSingle
import org.videolan.tools.*
import org.videolan.vlc.PlaybackService
import org.videolan.vlc.R
import org.videolan.vlc.gui.helpers.MISC_CHANNEL_ID
......@@ -238,8 +235,10 @@ class PopupManager constructor(private val service: PlaybackService) : PlaybackS
// else, go back 2 seconds, to compensate loading time
time = (if (service.length - time < 5000) 0 else 2000).toLong()
// Save position
if (service.isSeekable)
if (service.isSeekable) {
Settings.getInstance(service).putSingle(VIDEO_RESUME_TIME, time)
service.currentMediaLocation?.let { Settings.getInstance(service).putSingle(VIDEO_RESUME_URI, it) }
}
}
service.stop()
}
......
......@@ -1729,8 +1729,8 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
if (intent.hasExtra(PLAY_EXTRA_ITEM_TITLE))
itemTitle = extras.getString(PLAY_EXTRA_ITEM_TITLE)
}
if (startTime == 0L && savedTime > 0L) startTime = savedTime
val restorePlayback = hasMedia && currentMedia?.uri == videoUri
if (startTime == 0L && savedTime > 0L && restorePlayback) startTime = savedTime
var openedMedia: MediaWrapper? = null
val resumePlaylist = service.isValidIndex(positionInPlaylist)
......@@ -1775,7 +1775,8 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
return
} else {
val rTime = settings.getLong(VIDEO_RESUME_TIME, -1L)
if (rTime > 0) {
val lastUri = settings.getString(VIDEO_RESUME_URI, "")
if (rTime > 0 && service.currentMediaLocation == lastUri) {
if (askResume) {
showConfirmResumeDialog()
return
......
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