-
Notifications
You must be signed in to change notification settings - Fork 189
Open
Description
When trying to cast a HLS file that already contains multiple languages for audio and captions, we can't seem to change language on the CastPlayer based on the values from the ExoPlayer.
we are using a converter from mediaItem to mediaQueueItem as follows:
val mediaItemConverted = defaultMediaItemConverter.toMediaQueueItem(item)
val mediaInfo = mediaItemConverted.media
val mediaLoadRequestData = MediaLoadRequestData.Builder()
.setMediaInfo(mediaInfo)
.setCurrentTime(localPlayer.currentPosition)
.setAutoplay(localPlayer.isPlaying)
.setActiveTrackIds(longArrayOf(selectedCaption, selectedAudio))
.build()
remoteMediaClient.load(mediaLoadRequestData)
inside the MediaConverter we have this builder:
var selectedCaption = 0L
val captionsTracks = captions.mapIndexed { index, format ->
if (format.isSelected) {
selectedCaption = index.toLong()
}
MediaTrack.Builder(index.toLong(), TYPE_TEXT)
.setContentId(format.formatId)
.setName(format.label + " test")
.setLanguage(Locale(format.language))
.setSubtype(MediaTrack.SUBTYPE_SUBTITLES)
.build()
}
var selectedAudio = 0L
val audioTracks = audioLanguages.mapIndexed { index, format ->
val newIndex = captionsTracks.size + index
if (format.isSelected) {
selectedAudio = newIndex.toLong()
}
MediaTrack.Builder(newIndex.toLong(), TYPE_AUDIO)
.setContentId(format.formatId)
.setName(format.label + " test")
.setLanguage(Locale(format.language))
.build()
}
return MediaInfo.Builder(contentId)
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setVmapAdsRequest(vastAdsRequest)
.setContentType(localConfiguration.mimeType)
.setContentUrl(contentUrl)
.setMetadata(metadata)
.setMediaTracks(listOf(captionsTracks + audioTracks))
.setCustomData(getCustomData(mediaItem))
.build()
initially we tried to use the setMediaTracks
method (so we retrieved all the tracks from the local player and mapped them into media tracks) but the problem was that they were adding them 2 times in the list. (the ones that we added manually using setMediaTracks
and the ones that are added from the HLS file)
My question here is, is there a way for us to preselect a language when casting?
Metadata
Metadata
Assignees
Labels
No labels