mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
Fix a couple issues with transcoding (#261)
If playing with transcoding, changing tracks during playback will continue to transcode instead of possibly switching to direct play. Also support embedded subtitles that are being delivered externally. Fixes #256 Fixes #257
This commit is contained in:
parent
77755d04ba
commit
d3a3a2093a
2 changed files with 16 additions and 9 deletions
|
|
@ -141,6 +141,7 @@ class PlaybackViewModel
|
||||||
private lateinit var deviceProfile: DeviceProfile
|
private lateinit var deviceProfile: DeviceProfile
|
||||||
internal lateinit var itemId: UUID
|
internal lateinit var itemId: UUID
|
||||||
internal lateinit var item: BaseItem
|
internal lateinit var item: BaseItem
|
||||||
|
internal var forceTranscoding: Boolean = false
|
||||||
private var activityListener: TrackActivityPlaybackListener? = null
|
private var activityListener: TrackActivityPlaybackListener? = null
|
||||||
|
|
||||||
val nextUp = MutableLiveData<BaseItem?>()
|
val nextUp = MutableLiveData<BaseItem?>()
|
||||||
|
|
@ -177,6 +178,7 @@ class PlaybackViewModel
|
||||||
nextUp.value = null
|
nextUp.value = null
|
||||||
this.preferences = preferences
|
this.preferences = preferences
|
||||||
this.deviceProfile = deviceProfile
|
this.deviceProfile = deviceProfile
|
||||||
|
this.forceTranscoding = destination.forceTranscoding
|
||||||
val itemId = destination.itemId
|
val itemId = destination.itemId
|
||||||
this.itemId = itemId
|
this.itemId = itemId
|
||||||
val item = destination.item
|
val item = destination.item
|
||||||
|
|
@ -245,7 +247,7 @@ class PlaybackViewModel
|
||||||
item: BaseItem,
|
item: BaseItem,
|
||||||
positionMs: Long,
|
positionMs: Long,
|
||||||
itemPlayback: ItemPlayback? = null,
|
itemPlayback: ItemPlayback? = null,
|
||||||
forceTranscoding: Boolean = false,
|
forceTranscoding: Boolean = this.forceTranscoding,
|
||||||
): Boolean =
|
): Boolean =
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
Timber.i("Playing ${item.id}")
|
Timber.i("Playing ${item.id}")
|
||||||
|
|
@ -371,8 +373,8 @@ class PlaybackViewModel
|
||||||
subtitleIndex: Int?,
|
subtitleIndex: Int?,
|
||||||
positionMs: Long = 0,
|
positionMs: Long = 0,
|
||||||
userInitiated: Boolean,
|
userInitiated: Boolean,
|
||||||
enableDirectPlay: Boolean = true,
|
enableDirectPlay: Boolean = !this.forceTranscoding,
|
||||||
enableDirectStream: Boolean = true,
|
enableDirectStream: Boolean = !this.forceTranscoding,
|
||||||
) = withContext(Dispatchers.IO) {
|
) = withContext(Dispatchers.IO) {
|
||||||
val itemId = item.id
|
val itemId = item.id
|
||||||
val playerBackend = preferences.appPreferences.playbackPreferences.playerBackend
|
val playerBackend = preferences.appPreferences.playbackPreferences.playerBackend
|
||||||
|
|
@ -458,7 +460,7 @@ class PlaybackViewModel
|
||||||
audioStreamIndex = audioIndex,
|
audioStreamIndex = audioIndex,
|
||||||
subtitleStreamIndex = subtitleIndex,
|
subtitleStreamIndex = subtitleIndex,
|
||||||
mediaSourceId = currentItemPlayback.sourceId?.toServerString(),
|
mediaSourceId = currentItemPlayback.sourceId?.toServerString(),
|
||||||
alwaysBurnInSubtitleWhenTranscoding = null,
|
alwaysBurnInSubtitleWhenTranscoding = false,
|
||||||
maxStreamingBitrate = maxBitrate.toInt(),
|
maxStreamingBitrate = maxBitrate.toInt(),
|
||||||
enableDirectPlay = enableDirectPlay,
|
enableDirectPlay = enableDirectPlay,
|
||||||
enableDirectStream = enableDirectStream,
|
enableDirectStream = enableDirectStream,
|
||||||
|
|
@ -595,7 +597,7 @@ class PlaybackViewModel
|
||||||
player,
|
player,
|
||||||
playerBackend,
|
playerBackend,
|
||||||
source.supportsDirectPlay,
|
source.supportsDirectPlay,
|
||||||
audioIndex,
|
audioIndex.takeIf { transcodeType == PlayMethod.DIRECT_PLAY },
|
||||||
subtitleIndex,
|
subtitleIndex,
|
||||||
source,
|
source,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import com.github.damontecres.wholphin.preferences.PlayerBackend
|
||||||
import org.jellyfin.sdk.model.api.MediaSourceInfo
|
import org.jellyfin.sdk.model.api.MediaSourceInfo
|
||||||
import org.jellyfin.sdk.model.api.MediaStream
|
import org.jellyfin.sdk.model.api.MediaStream
|
||||||
import org.jellyfin.sdk.model.api.MediaStreamType
|
import org.jellyfin.sdk.model.api.MediaStreamType
|
||||||
|
import org.jellyfin.sdk.model.api.SubtitleDeliveryMethod
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
object TrackSelectionUtils {
|
object TrackSelectionUtils {
|
||||||
|
|
@ -211,12 +212,16 @@ val MediaSourceInfo.audioStreamCount: Int
|
||||||
?.count { it.type == MediaStreamType.AUDIO } ?: 0
|
?.count { it.type == MediaStreamType.AUDIO } ?: 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the [MediaStream] for the given subtitle index iff it is external
|
* Returns the [MediaStream] for the given subtitle index iff it is delivered external
|
||||||
*/
|
*/
|
||||||
fun MediaSourceInfo.findExternalSubtitle(subtitleIndex: Int?): MediaStream? =
|
fun MediaSourceInfo.findExternalSubtitle(subtitleIndex: Int?): MediaStream? = mediaStreams?.findExternalSubtitle(subtitleIndex)
|
||||||
|
|
||||||
|
fun List<MediaStream>.findExternalSubtitle(subtitleIndex: Int?): MediaStream? =
|
||||||
subtitleIndex?.let {
|
subtitleIndex?.let {
|
||||||
mediaStreams
|
firstOrNull {
|
||||||
?.firstOrNull { it.type == MediaStreamType.SUBTITLE && it.isExternal && it.index == subtitleIndex }
|
it.type == MediaStreamType.SUBTITLE && it.deliveryMethod == SubtitleDeliveryMethod.EXTERNAL &&
|
||||||
|
it.index == subtitleIndex
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class TrackSelectionResult(
|
data class TrackSelectionResult(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue