Forum Discussion

gooky's avatar
gooky
Visitor
10 years ago

How to change subtitles during playback

Hi,

I want the user to be able to choose between different subtitles, I use the code below. However any changes are not applied to the movie. 

What am i doing wrong?

sub init()
movieNode = CreateObject("roSGNode", "ContentNode")
movieNode.Title = "Movie name"

movieNode.StreamFormat = "mp4"
movieNode.URL = "http://187.188.137.31/test.m4v"
movieNode.SubtitleTracks = [{ TrackName: "http://187.188.137.31/latin.srt", Language:"spa", Description:"Spanish" }, { TrackName: "http://187.188.137.31/english.srt", Language:"eng", Description:"English" }]

m.player = m.top.findNode("player")
m.player.content = movieNode
m.player.control = "play"
m.player.setFocus(true)

end sub

5 Replies

  • im still coding my app in scene graph so i havent gotten to video playback as im building my menus en ui

    but according to what i read from the docs you should call m.player.globalCaptionMode("On"). By default captions is "Off"


    Subtitles may or may not be visible on the screen, depending upon the user's caption setting. Reading this field will return the identifier of the current subtitle track, and setting the field will change the track.



    you can learn more at

    https://sdkdocs.roku.com/display/sdkdoc/Video#Video-Fields
  • You are correct, one needs to make sure that it is on, however in my sandbox the captions are on by default, so this is not the problem right now 🙂

    Did I forget to mention... if I write the following:
    movieNode.SubtitleConfig = { TrackName: "http://187.188.137.31/latin.srt" }



    the movie starts with latin subtitles. However, changing the subtitle to English in closed caption dialog, it continues to show latin and not English as expected.
    It seems like a bug, because I can observe the field subtitleTrack on the player and it actually changes when changing subtitles in closed caption dialog. However no request is made to the server, thus no change of subtitle 😞
  • you could try to disable close caption setting the english subs and then enabling captions.
  • tifroz's avatar
    tifroz
    Streaming Star
    Did you ever figure it out? Would appreciate the solution as I am experiencing the same behavior!
  • what stream are u using? the above code works with HLS streams for me, DASH we are also having issues with the same code, same behaviour. 
    So according to their documentation:
    In the 8.0 firmware, automatic track selection based on a preferred caption language setting is introduced. Omit setting a URL here to avoid interfering with the automatic track selection. It is sufficient to add the URLs to SubtitleTracks.
    so u dont have to set the configSubtitle but just the  SubtitleTracks with an AA.