mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Merge pull request #2999 from Bnyro/master
Fix the time stamp parsing in the `PlayerFragment`
This commit is contained in:
commit
bd88a5a81b
@ -121,7 +121,7 @@ class AudioPlayerFragment : BaseFragment(), AudioPlayerOptions {
|
|||||||
NavigationHelper.navigateVideo(
|
NavigationHelper.navigateVideo(
|
||||||
context = requireContext(),
|
context = requireContext(),
|
||||||
videoId = PlayingQueue.getCurrent()?.url?.toID(),
|
videoId = PlayingQueue.getCurrent()?.url?.toID(),
|
||||||
timeStamp = playerService?.player?.currentPosition,
|
timeStamp = playerService?.player?.currentPosition?.div(1000),
|
||||||
keepQueue = true,
|
keepQueue = true,
|
||||||
forceVideo = true
|
forceVideo = true
|
||||||
)
|
)
|
||||||
|
@ -141,6 +141,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
private var playlistId: String? = null
|
private var playlistId: String? = null
|
||||||
private var channelId: String? = null
|
private var channelId: String? = null
|
||||||
private var keepQueue: Boolean = false
|
private var keepQueue: Boolean = false
|
||||||
|
private var timeStamp: Long? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Video information fetched at runtime
|
* Video information fetched at runtime
|
||||||
@ -228,6 +229,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
playlistId = it.getString(IntentData.playlistId)
|
playlistId = it.getString(IntentData.playlistId)
|
||||||
channelId = it.getString(IntentData.channelId)
|
channelId = it.getString(IntentData.channelId)
|
||||||
keepQueue = it.getBoolean(IntentData.keepQueue, false)
|
keepQueue = it.getBoolean(IntentData.keepQueue, false)
|
||||||
|
timeStamp = it.getLong(IntentData.timeStamp, 0L)
|
||||||
}
|
}
|
||||||
|
|
||||||
// broadcast receiver for PiP actions
|
// broadcast receiver for PiP actions
|
||||||
@ -716,6 +718,8 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
setupSeekbarPreview()
|
setupSeekbarPreview()
|
||||||
|
|
||||||
if (!streams.livestream) seekToWatchPosition()
|
if (!streams.livestream) seekToWatchPosition()
|
||||||
|
trySeekToTimeStamp()
|
||||||
|
|
||||||
exoPlayer.prepare()
|
exoPlayer.prepare()
|
||||||
if (!DataSaverMode.isEnabled(requireContext())) exoPlayer.play()
|
if (!DataSaverMode.isEnabled(requireContext())) exoPlayer.play()
|
||||||
|
|
||||||
@ -786,14 +790,9 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
handler.postDelayed(this@PlayerFragment::refreshLiveStatus, 100)
|
handler.postDelayed(this@PlayerFragment::refreshLiveStatus, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
// seek to saved watch position if available
|
/**
|
||||||
|
* Seek to saved watch position if available */
|
||||||
private fun seekToWatchPosition() {
|
private fun seekToWatchPosition() {
|
||||||
// support for time stamped links
|
|
||||||
val timeStamp: Long? = arguments?.getLong(IntentData.timeStamp)
|
|
||||||
if (timeStamp != null && timeStamp != 0L) {
|
|
||||||
exoPlayer.seekTo(timeStamp * 1000)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// browse the watch positions
|
// browse the watch positions
|
||||||
val position = try {
|
val position = try {
|
||||||
awaitQuery {
|
awaitQuery {
|
||||||
@ -808,6 +807,18 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seek to the time stamp passed by the intent arguments if available
|
||||||
|
*/
|
||||||
|
private fun trySeekToTimeStamp() {
|
||||||
|
// support for time stamped links
|
||||||
|
timeStamp?.let {
|
||||||
|
if (it != 0L) exoPlayer.seekTo(it * 1000)
|
||||||
|
}
|
||||||
|
// delete the time stamp because it already got consumed
|
||||||
|
timeStamp = null
|
||||||
|
}
|
||||||
|
|
||||||
// used for autoplay and skipping to next video
|
// used for autoplay and skipping to next video
|
||||||
private fun playNextVideo(nextId: String? = null) {
|
private fun playNextVideo(nextId: String? = null) {
|
||||||
val nextVideoId = nextId ?: PlayingQueue.getNext()
|
val nextVideoId = nextId ?: PlayingQueue.getNext()
|
||||||
|
Loading…
Reference in New Issue
Block a user