mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Fix bug where changing subtitles during playback doesn't work (#1352)
## Description Fixes an issue when changing subtitles during playback if you had previously explicitly chosen subtitles for that item but not chosen an audio track. ### Related issues I don't think there is a specific issue for this ### Testing Emulator ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
6afcfb469b
commit
461bad1ddd
3 changed files with 16 additions and 23 deletions
|
|
@ -8,7 +8,6 @@ import com.github.damontecres.wholphin.data.model.BaseItem
|
||||||
import com.github.damontecres.wholphin.data.model.CollectionFolderFilter
|
import com.github.damontecres.wholphin.data.model.CollectionFolderFilter
|
||||||
import com.github.damontecres.wholphin.data.model.DiscoverItem
|
import com.github.damontecres.wholphin.data.model.DiscoverItem
|
||||||
import com.github.damontecres.wholphin.data.model.GetItemsFilter
|
import com.github.damontecres.wholphin.data.model.GetItemsFilter
|
||||||
import com.github.damontecres.wholphin.data.model.ItemPlayback
|
|
||||||
import com.github.damontecres.wholphin.preferences.PlayerBackend
|
import com.github.damontecres.wholphin.preferences.PlayerBackend
|
||||||
import com.github.damontecres.wholphin.ui.data.SortAndDirection
|
import com.github.damontecres.wholphin.ui.data.SortAndDirection
|
||||||
import com.github.damontecres.wholphin.ui.detail.series.SeasonEpisodeIds
|
import com.github.damontecres.wholphin.ui.detail.series.SeasonEpisodeIds
|
||||||
|
|
@ -79,7 +78,6 @@ sealed class Destination(
|
||||||
data class Playback(
|
data class Playback(
|
||||||
val itemId: UUID,
|
val itemId: UUID,
|
||||||
val positionMs: Long,
|
val positionMs: Long,
|
||||||
val itemPlayback: ItemPlayback? = null,
|
|
||||||
val forceTranscoding: Boolean = false,
|
val forceTranscoding: Boolean = false,
|
||||||
val backend: PlayerBackend? = null,
|
val backend: PlayerBackend? = null,
|
||||||
) : Destination(true) {
|
) : Destination(true) {
|
||||||
|
|
|
||||||
|
|
@ -298,21 +298,18 @@ class PlaybackViewModel
|
||||||
this.forceTranscoding =
|
this.forceTranscoding =
|
||||||
(destination as? Destination.Playback)?.forceTranscoding ?: false
|
(destination as? Destination.Playback)?.forceTranscoding ?: false
|
||||||
val positionMs: Long
|
val positionMs: Long
|
||||||
val itemPlayback: ItemPlayback?
|
|
||||||
val forceTranscoding: Boolean
|
val forceTranscoding: Boolean
|
||||||
|
|
||||||
val itemId =
|
val itemId =
|
||||||
when (val d = destination) {
|
when (val d = destination) {
|
||||||
is Destination.Playback -> {
|
is Destination.Playback -> {
|
||||||
positionMs = d.positionMs
|
positionMs = d.positionMs
|
||||||
itemPlayback = d.itemPlayback
|
|
||||||
forceTranscoding = d.forceTranscoding
|
forceTranscoding = d.forceTranscoding
|
||||||
d.itemId
|
d.itemId
|
||||||
}
|
}
|
||||||
|
|
||||||
is Destination.PlaybackList -> {
|
is Destination.PlaybackList -> {
|
||||||
positionMs = 0
|
positionMs = 0
|
||||||
itemPlayback = null
|
|
||||||
forceTranscoding = false
|
forceTranscoding = false
|
||||||
d.itemId
|
d.itemId
|
||||||
}
|
}
|
||||||
|
|
@ -395,7 +392,6 @@ class PlaybackViewModel
|
||||||
play(
|
play(
|
||||||
firstItem,
|
firstItem,
|
||||||
positionMs,
|
positionMs,
|
||||||
itemPlayback,
|
|
||||||
forceTranscoding,
|
forceTranscoding,
|
||||||
)
|
)
|
||||||
if (!played) {
|
if (!played) {
|
||||||
|
|
@ -427,7 +423,6 @@ class PlaybackViewModel
|
||||||
private suspend fun play(
|
private suspend fun play(
|
||||||
playlistItem: PlaylistItem,
|
playlistItem: PlaylistItem,
|
||||||
positionMs: Long,
|
positionMs: Long,
|
||||||
itemPlayback: ItemPlayback? = null,
|
|
||||||
forceTranscoding: Boolean = this.forceTranscoding,
|
forceTranscoding: Boolean = this.forceTranscoding,
|
||||||
): Boolean =
|
): Boolean =
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
|
|
@ -463,9 +458,8 @@ class PlaybackViewModel
|
||||||
val base = item.data
|
val base = item.data
|
||||||
|
|
||||||
// Use the provided playback parameters or else check if the database has some
|
// Use the provided playback parameters or else check if the database has some
|
||||||
val playbackConfig =
|
val itemPlayback =
|
||||||
itemPlayback
|
serverRepository.currentUser.value?.let { user ->
|
||||||
?: serverRepository.currentUser.value?.let { user ->
|
|
||||||
itemPlaybackDao.getItem(user, base.id)?.let {
|
itemPlaybackDao.getItem(user, base.id)?.let {
|
||||||
Timber.v("Fetched itemPlayback from DB: %s", it)
|
Timber.v("Fetched itemPlayback from DB: %s", it)
|
||||||
if (it.sourceId != null) {
|
if (it.sourceId != null) {
|
||||||
|
|
@ -475,7 +469,7 @@ class PlaybackViewModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val mediaSource = streamChoiceService.chooseSource(base, playbackConfig)
|
val mediaSource = streamChoiceService.chooseSource(base, itemPlayback)
|
||||||
val plc = streamChoiceService.getPlaybackLanguageChoice(base)
|
val plc = streamChoiceService.getPlaybackLanguageChoice(base)
|
||||||
|
|
||||||
if (mediaSource == null) {
|
if (mediaSource == null) {
|
||||||
|
|
@ -531,7 +525,7 @@ class PlaybackViewModel
|
||||||
.chooseAudioStream(
|
.chooseAudioStream(
|
||||||
source = mediaSource,
|
source = mediaSource,
|
||||||
seriesId = base.seriesId,
|
seriesId = base.seriesId,
|
||||||
itemPlayback = playbackConfig,
|
itemPlayback = itemPlayback,
|
||||||
plc = plc,
|
plc = plc,
|
||||||
prefs = preferences,
|
prefs = preferences,
|
||||||
)
|
)
|
||||||
|
|
@ -543,7 +537,7 @@ class PlaybackViewModel
|
||||||
source = mediaSource,
|
source = mediaSource,
|
||||||
audioStream = audioStream,
|
audioStream = audioStream,
|
||||||
seriesId = base.seriesId,
|
seriesId = base.seriesId,
|
||||||
itemPlayback = playbackConfig,
|
itemPlayback = itemPlayback,
|
||||||
plc = plc,
|
plc = plc,
|
||||||
prefs = preferences,
|
prefs = preferences,
|
||||||
)?.index
|
)?.index
|
||||||
|
|
@ -551,7 +545,7 @@ class PlaybackViewModel
|
||||||
Timber.d("Selected mediaSource=${mediaSource.id}, audioIndex=$audioIndex, subtitleIndex=$subtitleIndex")
|
Timber.d("Selected mediaSource=${mediaSource.id}, audioIndex=$audioIndex, subtitleIndex=$subtitleIndex")
|
||||||
|
|
||||||
val itemPlaybackToUse =
|
val itemPlaybackToUse =
|
||||||
playbackConfig ?: ItemPlayback(
|
itemPlayback ?: ItemPlayback(
|
||||||
rowId = -1,
|
rowId = -1,
|
||||||
userId = -1,
|
userId = -1,
|
||||||
itemId = base.id,
|
itemId = base.id,
|
||||||
|
|
@ -821,6 +815,7 @@ class PlaybackViewModel
|
||||||
subtitleIndex,
|
subtitleIndex,
|
||||||
source,
|
source,
|
||||||
)
|
)
|
||||||
|
Timber.v("onTracksChanged: %s", result)
|
||||||
if (result.bothSelected) {
|
if (result.bothSelected) {
|
||||||
player.trackSelectionParameters =
|
player.trackSelectionParameters =
|
||||||
result.trackSelectionParameters
|
result.trackSelectionParameters
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ object TrackSelectionUtils {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
val audioSelected =
|
val audioSelected =
|
||||||
if (audioIndex != null && supportsDirectPlay) {
|
if (audioIndex != null && audioIndex >= 0 && supportsDirectPlay) {
|
||||||
val indexToFind =
|
val indexToFind =
|
||||||
calculateIndexToFind(
|
calculateIndexToFind(
|
||||||
audioIndex,
|
audioIndex,
|
||||||
|
|
@ -141,7 +141,7 @@ object TrackSelectionUtils {
|
||||||
}
|
}
|
||||||
chosenTrack != null
|
chosenTrack != null
|
||||||
} else {
|
} else {
|
||||||
audioIndex == null
|
true
|
||||||
}
|
}
|
||||||
return TrackSelectionResult(paramsBuilder.build(), audioSelected, subtitleSelected)
|
return TrackSelectionResult(paramsBuilder.build(), audioSelected, subtitleSelected)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue