Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
gooky
Visitor

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
0 Kudos
5 REPLIES 5
adrianc1982
Visitor

Re: How to change subtitles during playback

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
0 Kudos
gooky
Visitor

Re: How to change subtitles during playback

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 😞
0 Kudos
adrianc1982
Visitor

Re: How to change subtitles during playback

you could try to disable close caption setting the english subs and then enabling captions.
0 Kudos
tifroz
Streaming Star

Re: How to change subtitles during playback

Did you ever figure it out? Would appreciate the solution as I am experiencing the same behavior!
0 Kudos
gomad
Roku Guru

Re: How to change subtitles during playback

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 intr...
so u dont have to set the configSubtitle but just the  SubtitleTracks with an AA.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.