-
Notifications
You must be signed in to change notification settings - Fork 769
Description
Steps to reproduce
- Install repo
https://raw.githubusercontent.com/Sushan64/NetMirror-Extension/refs/heads/builds/Netflix.json - Download Netmirror plugin
- Open PrimeVideo Plugin from the list of available plugins
- Search in the plugin for any blockbuster such as
fallout - Play any episode
- In the player tap on the change Audio Track button at the bottom
- Select the second Spanish (or second French) track and apply changes
- Tap Again in the tap on the change Audio Track button
ERROR: Cloudstream has not selected the right track, but the first one since there is more than one track with the same ID. Having more than one track with the same ID is common in Spanish and French content.
Expected behavior
Cloudstream should provide exoplayer with the right audio track and the second audio track should be selected and played.
Actual behavior
Cloudstream is not playing the selected track
Cloudstream version and commit hash
4.6.1-PRE build ee1009a
Android version
Android 14
Logcat
Other details
ROOT CAUSE ANALYSIS:
override fun setPreferredAudioTrack(trackLanguage: String?, id: String?) uses the track ID for selecting the audio track. But it is common to see several tracks with the same Id. By using the Id it is impossible to use alternate tracks sharing the same Id. Only unique value per track should be used, and the Track Index seems to be the only value capable of ensure success.
PROPOSED SOLUTION:
The function above in file CS3IPlayer.kt should receive the desired audio track index which is unique per track in a stream and not the Id.
This is the proposed function:
override fun setPreferredAudioTrack(trackLanguage: String?, trackNum: Int?) {
preferredAudioTrackLanguage = trackLanguage
val player = exoPlayer ?: return
val tracks = player.currentTracks
// Find the audio group
val audioGroup = tracks.groups
.firstOrNull { it.type == TRACK_TYPE_AUDIO }
// If a track number is provided, try to override by index
if (audioGroup != null && trackNum != null) {
if (trackNum in 0 until audioGroup.length) {
val override = TrackSelectionOverride(
audioGroup.mediaTrackGroup,
listOf(trackNum) // <-- select by track number
)
player.trackSelectionParameters =
player.trackSelectionParameters
.buildUpon()
.clearOverridesOfType(TRACK_TYPE_AUDIO)
.addOverride(override)
.build()
return
}
}
// Fallback: use preferred language
player.trackSelectionParameters =
player.trackSelectionParameters
.buildUpon()
.setPreferredAudioLanguage(trackLanguage)
.build()
}The function is called only once, when a new audio track is selected. That is performed in function override fun showTracksDialogue() in file 'GeneratorPlayer.kt'
On click, the block of code should be:
binding.applyBtt.setOnClickListener {
// Line not needed: val currentTrack = currentAudioTracks.getOrNull(audioIndexStart)
player.setPreferredAudioTrack(
currentTrack?.language, audioIndexStart // not currentTrack?.id
)
val currentVideo = currentVideoTracks.getOrNull(videoIndex)
val width = currentVideo?.width ?: NO_VALUE
val height = currentVideo?.height ?: NO_VALUE
if (width != NO_VALUE && height != NO_VALUE) {
player.setMaxVideoSize(width, height, currentVideo?.id)
}
trackDialog.dismissSafe(activity)
}This way the track selection will work as intended, even when there are more than one audio track with the same Id, something common for Spanish and French audio tracks.
Acknowledgements
- I am sure my issue is related to the app and NOT some extension.
- I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open issue.
- I have written a short but informative title.
- I have updated the app to pre-release version Latest.
- I will fill out all of the requested information in this form.