mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 15:30:31 +05:30
Merge pull request #7237 from Bnyro/master
fix: urls with timestamps don't work properly
This commit is contained in:
commit
ed351269df
@ -50,7 +50,7 @@ open class OnlinePlayerService : AbstractPlayerService() {
|
||||
// PlaylistId/ChannelId for autoplay
|
||||
private var playlistId: String? = null
|
||||
private var channelId: String? = null
|
||||
private var startTimestamp: Long? = null
|
||||
private var startTimestampSeconds: Long? = null
|
||||
|
||||
/**
|
||||
* The response that gets when called the Api.
|
||||
@ -105,7 +105,7 @@ open class OnlinePlayerService : AbstractPlayerService() {
|
||||
setVideoId(playerData.videoId)
|
||||
playlistId = playerData.playlistId
|
||||
channelId = playerData.channelId
|
||||
startTimestamp = playerData.timestamp
|
||||
startTimestampSeconds = playerData.timestamp
|
||||
|
||||
if (!playerData.keepQueue) PlayingQueue.clear()
|
||||
|
||||
@ -115,8 +115,8 @@ open class OnlinePlayerService : AbstractPlayerService() {
|
||||
override suspend fun startPlayback() {
|
||||
super.startPlayback()
|
||||
|
||||
val timestamp = startTimestamp ?: 0L
|
||||
startTimestamp = null
|
||||
val timestampMs = startTimestampSeconds?.times(1000) ?: 0L
|
||||
startTimestampSeconds = null
|
||||
|
||||
streams = withContext(Dispatchers.IO) {
|
||||
try {
|
||||
@ -152,16 +152,16 @@ open class OnlinePlayerService : AbstractPlayerService() {
|
||||
}
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
playAudio(timestamp)
|
||||
playAudio(timestampMs)
|
||||
}
|
||||
}
|
||||
|
||||
private fun playAudio(seekToPosition: Long) {
|
||||
private fun playAudio(seekToPositionMs: Long) {
|
||||
setStreamSource()
|
||||
|
||||
// seek to the previous position if available
|
||||
if (seekToPosition != 0L) {
|
||||
exoPlayer?.seekTo(seekToPosition)
|
||||
if (seekToPositionMs != 0L) {
|
||||
exoPlayer?.seekTo(seekToPositionMs)
|
||||
} else if (watchPositionsEnabled) {
|
||||
DatabaseHelper.getWatchPositionBlocking(videoId)?.let {
|
||||
if (!DatabaseHelper.isVideoWatched(it, streams?.duration)) exoPlayer?.seekTo(it)
|
||||
|
@ -133,15 +133,22 @@ class ShareDialog : DialogFragment() {
|
||||
// only available for custom instances
|
||||
else -> customInstanceUrl!!.toString().trimEnd('/')
|
||||
}
|
||||
var url = when {
|
||||
shareObjectType == ShareObjectType.VIDEO && host == YOUTUBE_FRONTEND_URL -> "$YOUTUBE_SHORT_URL/$id"
|
||||
shareObjectType == ShareObjectType.VIDEO -> "$host/watch?v=$id"
|
||||
shareObjectType == ShareObjectType.PLAYLIST -> "$host/playlist?list=$id"
|
||||
else -> "$host/channel/$id"
|
||||
}
|
||||
val url = when (shareObjectType) {
|
||||
ShareObjectType.VIDEO -> {
|
||||
val queryParams = mutableListOf<String>()
|
||||
if (host != YOUTUBE_FRONTEND_URL) {
|
||||
queryParams.add("v=${id}")
|
||||
}
|
||||
if (binding.timeCodeSwitch.isChecked) {
|
||||
queryParams += "t=${binding.timeStamp.text}"
|
||||
}
|
||||
val baseUrl = if (host == YOUTUBE_FRONTEND_URL) "$YOUTUBE_SHORT_URL/$id" else "$host/watch"
|
||||
|
||||
if (shareObjectType == ShareObjectType.VIDEO && binding.timeCodeSwitch.isChecked) {
|
||||
url += "&t=${binding.timeStamp.text}"
|
||||
if (queryParams.isEmpty()) baseUrl
|
||||
else baseUrl + "?" + queryParams.joinToString("&")
|
||||
}
|
||||
ShareObjectType.PLAYLIST -> "$host/playlist?list=$id"
|
||||
else -> "$host/channel/$id"
|
||||
}
|
||||
|
||||
return url
|
||||
|
Loading…
x
Reference in New Issue
Block a user