Can't get subtitles to work in Chromecast when casting from Android

We implemented without problem subtitles in our Android app - they show in UI when activated. However when casting to Chromecast they do not reflect on the receiver.
We are using Bitmovins receiver and not a custom one, so it should work.
(FAQs: Bitmovin Docs - Player FAQ - Why are subtitles not shown when casting from Android/iOS to a custom receiver app?)

SDK version: 3.18.1

Code snippet below on how subs are inserted and casting.

Are we missing something?

Thanks!

Hi @soporte,

if you are using the Bitmovin Web UI the subtitles should be available for selection through the UI once the cast session is successfully connected.
If are implementing a native UI you should be able to select a subtitle track using the API when receiving the SubtitleTracksChanged event after connecting to the cast session. The event contains information about the available tracks.

Hope this helps, feel free to reach out again if something is unclear.

Hi @Lukas , Gonzalo here, We’re actually implementing a custom UI with the SubtitleView example with Kotlin (Android SDK), I saw that SubtitleTracksChanged Source Event is triggering once when we set the initial config, but then when we change via a custom Dialog, no event is triggered, with or without ChromeCast on. Without ChromeCast, subtitles appear with no problem in our view, but when ChromeCast is on, no subtitle is casted to the screen after we set the SubtitleTrack to the player and/or Source, which you can see on the ScreenShot in the first post. We don’t know if with a custom UI we lost this feature or we need to send the track to the cast context with another API.

Hi @Lukas , Gonzalo here, We’re actually implementing a custom UI with the SubtitleView example with Kotlin (Android SDK), I saw that SubtitleTracksChanged Source Event is triggering once when we set the initial config, but then when we change via a custom Dialog, no event is triggered, with or without ChromeCast on. Without ChromeCast, subtitles appear with no problem in our view, but when ChromeCast is on, no subtitle is casted to the screen after we set the SubtitleTrack to the player and/or Source, which you can see on the ScreenShot in the first post. We don’t know if with a custom UI we lost this feature or we need to send the track to the cast context with another API.

Here is our custom UI. As you can see, subtitles works fine.

[Drive url shows an error when posted] https://drive.google.com/drive/folders/1KTyrTFUi6WeeUjJy1_gPZjeCXnlt3hZc?usp=sharing

But when we start ChromeCast, no sub is shown.

Just for the test, we put some logs and resetting the selected SubtitleTrack to the player and Source.

bView.bitmovinPlayerView.player?.source?.on(SourceEvent.SubtitleTracksChanged::class.java) {
            Log.e("stt changed", "triggered on cast ${bView.bitmovinPlayerView.player?.isCasting}")
            selectedSubtitleTrack?.let {
                Log.e("selectedSubtitleTrack", "${selectedSubtitleTrack?.label}")
                bView.bitmovinPlayerView.player?.source?.setSubtitleTrack(selectedSubtitleTrack?.id)
                bView.bitmovinPlayerView.player?.setSubtitle(selectedSubtitleTrack?.id)
            }
            if(it.oldSubtitleTracks.isNotEmpty()){
                Log.e("old stt changed", "yes: ${it.oldSubtitleTracks.size}")
            }
        }

Logs ScreenShot is in Drive.

Hi Gonzalo,
first things first: It is very well possible that the cast device supports a different set of subtitle tracks as it is a different device. Does not mean that this is necessarily the case here, just keep it in mind.

Next thing I would like to clarify a few details around the subtitle API:
SourceEvent.SubtitleTracksChanged is emitted whenever the list of available subtitle tracks changes. E.g. if there are different tracks available on the cast device, you will receive this event once cast is connected.
SourceEvent.SubtitleTrackChanged is emitted whenever the selected changed, so whenever you call Source.setSubtitleTrack with a subtitle track id that is part of the current Source.availableSubtitleTracks.

Now to your code snippet:
This looks like you are trying to re-select the same subtitle track as selected locally on the cast receiver.
I don’t see how you populate the local selectedSubtitleTrack variable, but I assume that this is the locally selected subtitle track.
Before selecting it on the source while casting you should verify that the list of available subtitle tracks actually contains a track with this specific id. As this track information is exposed from the cast device, it can be that the tracks look different.

Maybe you can try something similar to this:

        source.on<SourceEvent.SubtitleTracksChanged> { event ->
            Log.v("SubtitleHandling", "Received SubtitleTracksChanged with $event")

            val newTracks = event.newSubtitleTracks
            
            val trackToSelect = newTracks.firstOrNull { it.id == selectedSubtitleTrack?.id }
                ?: newTracks.firstOrNull { it.language == selectedSubtitleTrack?.language }

            source.setSubtitleTrack(trackToSelect?.id)
            Log.v( "SubtitleHandling", "selected track id: ${trackToSelect?.id}  language: ${trackToSelect?.language} label: ${trackToSelect?.label}." )
        }
1 Like

Thanks @Lukas we will check the format and the ChromeCast device version as you said it.

We gonna use your recommendation and test again, but now that we know, maybe is a format problem, the player content use for now only .SRT subtitles. Thank you very much for the quick response!