Skip to content
Snippets Groups Projects
Commit 44d64429 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Player: Init progress with start time value

parent 6d27fa61
No related branches found
No related tags found
No related merge requests found
Pipeline #6095 passed with stage
in 4 minutes and 1 second
......@@ -53,8 +53,8 @@ class PreviewVideoInputService : TvInputService(), CoroutineScope {
}
try {
val media = Media(VLCInstance.get(this@PreviewVideoInputService), mw.uri)
val start = if (mw.length <= 0L) 0 else mw.length.random()/1000
media.addOption(":start-time=$start")
val start = if (mw.length <= 0L) 0L else mw.length.random()
media.addOption(":start-time=${start/1000L}")
player.getVout()?.apply {
setVideoSurface(surface, null)
attachViews(null)
......@@ -62,7 +62,7 @@ class PreviewVideoInputService : TvInputService(), CoroutineScope {
}
player.setVideoAspectRatio(null)
player.setVideoScale(0f)
player.startPlayback(media, this@PreviewSession)
player.startPlayback(media, this@PreviewSession, start)
notifyVideoAvailable()
} catch (e: IOException) {
Log.e(TAG, "Could not prepare media player", e)
......
......@@ -73,9 +73,9 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
}
private var mediaplayerEventListener: MediaPlayerEventListener? = null
internal suspend fun startPlayback(media: Media, listener: MediaPlayerEventListener) {
internal suspend fun startPlayback(media: Media, listener: MediaPlayerEventListener, time: Long) {
mediaplayerEventListener = listener
resetPlaybackState(media.duration)
resetPlaybackState(time, media.duration)
mediaplayer.setEventListener(null)
withContext(Dispatchers.IO) { if (!mediaplayer.isReleased) mediaplayer.media = media.apply { if (hasRenderer) parse() } }
mediaplayer.setEventListener(this@PlayerController)
......@@ -86,11 +86,11 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
}
}
private fun resetPlaybackState(duration: Long) {
private fun resetPlaybackState(time: Long, duration: Long) {
seekable = true
pausable = true
lastTime = 0L
updateProgress(0L, duration)
lastTime = time
updateProgress(time, duration)
}
@MainThread
......
......@@ -294,7 +294,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
}
val start = getStartTime(mw)
val media = Media(VLCInstance.get(service), uri)
media.addOption(":start-time=$start")
media.addOption(":start-time=${start/1000L}")
VLCOptions.setMediaOptions(media, ctx, flags or mw.flags)
/* keeping only video during benchmark */
if (isBenchmark) {
......@@ -306,13 +306,13 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
}
}
media.setEventListener(this@PlaylistManager)
player.startPlayback(media, mediaplayerEventListener)
player.startPlayback(media, mediaplayerEventListener, start)
player.setSlaves(media, mw)
newMedia = true
determinePrevAndNextIndices()
service.onNewPlayback()
} else { //Start VideoPlayer for first video, it will trigger playIndex when ready.
player.stop()
if (player.isPlaying()) player.stop()
VideoPlayerActivity.startOpened(ctx, mw.uri, currentIndex)
}
}
......@@ -620,7 +620,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
else -> savedTime
}
savedTime = 0L
return start/1000L
return start
}
@Synchronized
......
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