mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +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
|
||||
internal lateinit var itemId: UUID
|
||||
internal lateinit var item: BaseItem
|
||||
internal var forceTranscoding: Boolean = false
|
||||
private var activityListener: TrackActivityPlaybackListener? = null
|
||||
|
||||
val nextUp = MutableLiveData<BaseItem?>()
|
||||
|
|
@ -177,6 +178,7 @@ class PlaybackViewModel
|
|||
nextUp.value = null
|
||||
this.preferences = preferences
|
||||
this.deviceProfile = deviceProfile
|
||||
this.forceTranscoding = destination.forceTranscoding
|
||||
val itemId = destination.itemId
|
||||
this.itemId = itemId
|
||||
val item = destination.item
|
||||
|
|
@ -245,7 +247,7 @@ class PlaybackViewModel
|
|||
item: BaseItem,
|
||||
positionMs: Long,
|
||||
itemPlayback: ItemPlayback? = null,
|
||||
forceTranscoding: Boolean = false,
|
||||
forceTranscoding: Boolean = this.forceTranscoding,
|
||||
): Boolean =
|
||||
withContext(Dispatchers.IO) {
|
||||
Timber.i("Playing ${item.id}")
|
||||
|
|
@ -371,8 +373,8 @@ class PlaybackViewModel
|
|||
subtitleIndex: Int?,
|
||||
positionMs: Long = 0,
|
||||
userInitiated: Boolean,
|
||||
enableDirectPlay: Boolean = true,
|
||||
enableDirectStream: Boolean = true,
|
||||
enableDirectPlay: Boolean = !this.forceTranscoding,
|
||||
enableDirectStream: Boolean = !this.forceTranscoding,
|
||||
) = withContext(Dispatchers.IO) {
|
||||
val itemId = item.id
|
||||
val playerBackend = preferences.appPreferences.playbackPreferences.playerBackend
|
||||
|
|
@ -458,7 +460,7 @@ class PlaybackViewModel
|
|||
audioStreamIndex = audioIndex,
|
||||
subtitleStreamIndex = subtitleIndex,
|
||||
mediaSourceId = currentItemPlayback.sourceId?.toServerString(),
|
||||
alwaysBurnInSubtitleWhenTranscoding = null,
|
||||
alwaysBurnInSubtitleWhenTranscoding = false,
|
||||
maxStreamingBitrate = maxBitrate.toInt(),
|
||||
enableDirectPlay = enableDirectPlay,
|
||||
enableDirectStream = enableDirectStream,
|
||||
|
|
@ -595,7 +597,7 @@ class PlaybackViewModel
|
|||
player,
|
||||
playerBackend,
|
||||
source.supportsDirectPlay,
|
||||
audioIndex,
|
||||
audioIndex.takeIf { transcodeType == PlayMethod.DIRECT_PLAY },
|
||||
subtitleIndex,
|
||||
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.MediaStream
|
||||
import org.jellyfin.sdk.model.api.MediaStreamType
|
||||
import org.jellyfin.sdk.model.api.SubtitleDeliveryMethod
|
||||
import timber.log.Timber
|
||||
|
||||
object TrackSelectionUtils {
|
||||
|
|
@ -211,12 +212,16 @@ val MediaSourceInfo.audioStreamCount: Int
|
|||
?.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 {
|
||||
mediaStreams
|
||||
?.firstOrNull { it.type == MediaStreamType.SUBTITLE && it.isExternal && it.index == subtitleIndex }
|
||||
firstOrNull {
|
||||
it.type == MediaStreamType.SUBTITLE && it.deliveryMethod == SubtitleDeliveryMethod.EXTERNAL &&
|
||||
it.index == subtitleIndex
|
||||
}
|
||||
}
|
||||
|
||||
data class TrackSelectionResult(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue