15

I can show subtitle(webvtt) using android app using following code

MediaTrack subtitle = new MediaTrack.Builder(0, MediaTrack.TYPE_TEXT)
                            .setName("English")
                            .setSubtype(MediaTrack.SUBTYPE_SUBTITLES)
                            .setContentId(mediaObject.getSubtitleUrl())
                            .setLanguage(Locale.getDefault())
                            .build();

                    tracks.add(subtitle);

My problem is, this approach works when media is loaded initially to Chromecast, so if I want add subtitle later while media is playing I have to reload media again.

Is there work around this? As I have seen some apps doing the desired behavior.

ingsaurabh
  • 15,249
  • 7
  • 52
  • 81

1 Answers1

1

You'd need to load your media with subtitles included from the beginning. You can have subtitles turned off and then allow user to select one and turn that on or off at run time but in order to have things working, subtitles need to be included at the load time of media.

Ali Naddaf
  • 16,951
  • 2
  • 21
  • 28
  • I understand that we can toggle the subtitle on/off at runtime if subtitle are included when media is loaded, but If user wants to load some other subtitle while media is playing then we have to reload media with new subtitle, so is there way to bypass this – ingsaurabh Dec 19 '16 at 08:55
  • No, the current SDK doesn't support that. Feel free to open a feature request at https://code.google.com/p/google-cast-sdk/issues/list – Ali Naddaf Dec 19 '16 at 14:54