mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Fix immediate transition to next video when starting player
This commit is contained in:
parent
ada94e0bb4
commit
10c9978bc8
@ -63,8 +63,8 @@ data class Streams(
|
|||||||
path = Paths.get(""),
|
path = Paths.get(""),
|
||||||
url = subtitles.find {
|
url = subtitles.find {
|
||||||
it.code == subCode
|
it.code == subCode
|
||||||
}?.url?.let { ProxyHelper.unwrapUrl(it) },
|
}?.url?.let { ProxyHelper.unwrapUrl(it) }
|
||||||
),
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,12 @@ object DashHelper {
|
|||||||
val formats: MutableList<PipedStream> = mutableListOf()
|
val formats: MutableList<PipedStream> = mutableListOf()
|
||||||
)
|
)
|
||||||
|
|
||||||
fun createManifest(streams: Streams, supportsHdr: Boolean, audioOnly: Boolean = false, rewriteUrls: Boolean): String {
|
fun createManifest(
|
||||||
|
streams: Streams,
|
||||||
|
supportsHdr: Boolean,
|
||||||
|
audioOnly: Boolean = false,
|
||||||
|
rewriteUrls: Boolean
|
||||||
|
): String {
|
||||||
val builder = builderFactory.newDocumentBuilder()
|
val builder = builderFactory.newDocumentBuilder()
|
||||||
|
|
||||||
val doc = builder.newDocument()
|
val doc = builder.newDocument()
|
||||||
@ -137,7 +142,11 @@ object DashHelper {
|
|||||||
return writer.toString()
|
return writer.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createAudioRepresentation(doc: Document, stream: PipedStream, rewriteUrls: Boolean): Element {
|
private fun createAudioRepresentation(
|
||||||
|
doc: Document,
|
||||||
|
stream: PipedStream,
|
||||||
|
rewriteUrls: Boolean
|
||||||
|
): Element {
|
||||||
val representation = doc.createElement("Representation")
|
val representation = doc.createElement("Representation")
|
||||||
representation.setAttribute("bandwidth", stream.bitrate.toString())
|
representation.setAttribute("bandwidth", stream.bitrate.toString())
|
||||||
representation.setAttribute("codecs", stream.codec!!)
|
representation.setAttribute("codecs", stream.codec!!)
|
||||||
@ -167,7 +176,11 @@ object DashHelper {
|
|||||||
return representation
|
return representation
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createVideoRepresentation(doc: Document, stream: PipedStream, rewriteUrls: Boolean): Element {
|
private fun createVideoRepresentation(
|
||||||
|
doc: Document,
|
||||||
|
stream: PipedStream,
|
||||||
|
rewriteUrls: Boolean
|
||||||
|
): Element {
|
||||||
val representation = doc.createElement("Representation")
|
val representation = doc.createElement("Representation")
|
||||||
representation.setAttribute("codecs", stream.codec!!)
|
representation.setAttribute("codecs", stream.codec!!)
|
||||||
representation.setAttribute("bandwidth", stream.bitrate.toString())
|
representation.setAttribute("bandwidth", stream.bitrate.toString())
|
||||||
|
@ -48,9 +48,13 @@ object ProxyHelper {
|
|||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unwrapImageUrl(url: String): String = if (
|
fun unwrapImageUrl(url: String) = if (
|
||||||
!PreferenceHelper.getBoolean(PreferenceKeys.DISABLE_VIDEO_IMAGE_PROXY, false)
|
!PreferenceHelper.getBoolean(PreferenceKeys.DISABLE_VIDEO_IMAGE_PROXY, false)
|
||||||
) url else unwrapUrl(url)
|
) {
|
||||||
|
url
|
||||||
|
} else {
|
||||||
|
unwrapUrl(url)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a proxied Piped url to a YouTube url that's not proxied
|
* Convert a proxied Piped url to a YouTube url that's not proxied
|
||||||
|
@ -25,7 +25,6 @@ import com.github.libretube.api.obj.Streams
|
|||||||
import com.github.libretube.constants.BACKGROUND_CHANNEL_ID
|
import com.github.libretube.constants.BACKGROUND_CHANNEL_ID
|
||||||
import com.github.libretube.constants.IntentData
|
import com.github.libretube.constants.IntentData
|
||||||
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
|
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
|
||||||
import com.github.libretube.constants.PreferenceKeys
|
|
||||||
import com.github.libretube.db.DatabaseHolder.Database
|
import com.github.libretube.db.DatabaseHolder.Database
|
||||||
import com.github.libretube.db.obj.WatchPosition
|
import com.github.libretube.db.obj.WatchPosition
|
||||||
import com.github.libretube.enums.SbSkipOptions
|
import com.github.libretube.enums.SbSkipOptions
|
||||||
@ -35,7 +34,6 @@ import com.github.libretube.extensions.toID
|
|||||||
import com.github.libretube.helpers.PlayerHelper
|
import com.github.libretube.helpers.PlayerHelper
|
||||||
import com.github.libretube.helpers.PlayerHelper.checkForSegments
|
import com.github.libretube.helpers.PlayerHelper.checkForSegments
|
||||||
import com.github.libretube.helpers.PlayerHelper.loadPlaybackParams
|
import com.github.libretube.helpers.PlayerHelper.loadPlaybackParams
|
||||||
import com.github.libretube.helpers.PreferenceHelper
|
|
||||||
import com.github.libretube.helpers.ProxyHelper
|
import com.github.libretube.helpers.ProxyHelper
|
||||||
import com.github.libretube.obj.PlayerNotificationData
|
import com.github.libretube.obj.PlayerNotificationData
|
||||||
import com.github.libretube.parcelable.PlayerData
|
import com.github.libretube.parcelable.PlayerData
|
||||||
@ -303,7 +301,12 @@ class OnlinePlayerService : LifecycleService() {
|
|||||||
|
|
||||||
val (uri, mimeType) = if (streams.audioStreams.isNotEmpty()) {
|
val (uri, mimeType) = if (streams.audioStreams.isNotEmpty()) {
|
||||||
val disableProxy = ProxyHelper.shouldDisableProxy(streams.videoStreams.first().url!!)
|
val disableProxy = ProxyHelper.shouldDisableProxy(streams.videoStreams.first().url!!)
|
||||||
PlayerHelper.createDashSource(streams, this, true, disableProxy) to MimeTypes.APPLICATION_MPD
|
PlayerHelper.createDashSource(
|
||||||
|
streams,
|
||||||
|
this,
|
||||||
|
true,
|
||||||
|
disableProxy
|
||||||
|
) to MimeTypes.APPLICATION_MPD
|
||||||
} else {
|
} else {
|
||||||
ProxyHelper.unwrapStreamUrl(streams.hls.orEmpty()).toUri() to MimeTypes.APPLICATION_M3U8
|
ProxyHelper.unwrapStreamUrl(streams.hls.orEmpty()).toUri() to MimeTypes.APPLICATION_M3U8
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
*/
|
*/
|
||||||
private var sId: Int = 0
|
private var sId: Int = 0
|
||||||
private var eId: Int = 0
|
private var eId: Int = 0
|
||||||
private var transitioning = false
|
private var transitioning = true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* for the player
|
* for the player
|
||||||
@ -1305,10 +1305,18 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
false
|
false
|
||||||
) && streams.videoStreams.isNotEmpty() -> {
|
) && streams.videoStreams.isNotEmpty() -> {
|
||||||
// only use the dash manifest generated by YT if either it's a livestream or no other source is available
|
// only use the dash manifest generated by YT if either it's a livestream or no other source is available
|
||||||
val dashUri = if (streams.livestream && streams.dash != null) ProxyHelper.unwrapStreamUrl(streams.dash!!).toUri() else {
|
val dashUri =
|
||||||
val shouldDisableProxy = ProxyHelper.shouldDisableProxy(streams.videoStreams.first().url!!)
|
if (streams.livestream && streams.dash != null) ProxyHelper.unwrapStreamUrl(
|
||||||
PlayerHelper.createDashSource(streams, requireContext(), disableProxy = shouldDisableProxy)
|
streams.dash!!
|
||||||
}
|
).toUri() else {
|
||||||
|
val shouldDisableProxy =
|
||||||
|
ProxyHelper.shouldDisableProxy(streams.videoStreams.first().url!!)
|
||||||
|
PlayerHelper.createDashSource(
|
||||||
|
streams,
|
||||||
|
requireContext(),
|
||||||
|
disableProxy = shouldDisableProxy
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
dashUri to MimeTypes.APPLICATION_MPD
|
dashUri to MimeTypes.APPLICATION_MPD
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user