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: 
srbsdean
Visitor

Captions not Working

I have tried several different ways to get my captions to appear on my channel. I looked at the current method for enabling captions found in the blog post here: http://blog.roku.com/developer/2014/01/16/new-closed-caption-features-for-brightscript-developers/, and so I tried and this is what I came up with. I am using the Video Player example and so on my appVideoScreen I have this:
Function showVideoScreen(episode As Object)

if type(episode) <> "roAssociativeArray" then
print "invalid data passed to showVideoScreen"
return -1
endif

port = CreateObject("roMessagePort")
screen = CreateObject("roVideoScreen")
screen.SetMessagePort(port)

screen.SetPositionNotificationPeriod(30)
screen.SetContent(episode)
screen.Show()

'Uncomment his line to dump the contents of the episode to be played
'PrintAA(episode)

while true
msg = wait(0, port)

if type(msg) = "roVideoScreenEvent" then
print "showHomeScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isfullresult()
print "Video Completed Playback Normally"
RegDelete(episode.ContentId)
print "deleted bookmark for playback position"
else if msg.isScreenClosed()
print "Screen closed"
exit while
elseif msg.isRequestFailed()
print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
RegWrite(episode.ContentId, nowpos.toStr())
else
print "Unexpected event type: "; msg.GetType()
end if
else
print "Unexpected message class: "; type(msg)
end if
end while

End Function

Function EnableCaptions(player as object) as void
di = CreateObject("roDeviceInfo")
captionsMode = di.GetCaptionsMode()

if (captionsMode = "On")
player.ShowSubtitle(true)
player.ShowSubtitleOnReplay(false)
else if (captionsMode = "Off")
player.ShowSubtitle(false)
player.ShowSubtitleOnReplay(false)
else if (captionsMode = "Instant Replay")
player.ShowSubtitle(false)
player.ShowSubtitleOnReplay(true)
endif
End Function
and then I put the caption URL into my XML Document like this:
<item sdImg="http://dsoeehox1xjyp.cloudfront.net/roku/SHEPHERDS/images/series-images/7430-SD.jpg" hdImg="http://dsoeehox1xjyp.cloudfront.net/roku/SHEPHERDS/images/series-images/7430-HD.jpg">
<title>Current Series Video 1</title>
<contentId>1001</contentId>
<contentType>episode</contentType>
<contentQuality>HD</contentQuality>
<streamFormat>MP4</streamFormat>
<subtitleURL>http://selectbroadcasting.org/roku/examples/source/SHEPHERDS/CC/7430.srt</subtitleURL>

<media>

<streamQuality>HD</streamQuality>
<streamBitrate>3000</streamBitrate>
<streamUrl>http://dsoeehox1xjyp.cloudfront.net/roku/SHEPHERDS/video/7430_1080p-2928.mp4</streamUrl>
</media>
<media>
<streamQuality>HD</streamQuality>
<streamBitrate>1800</streamBitrate>
<streamUrl>http://dsoeehox1xjyp.cloudfront.net/roku/SHEPHERDS/video/7430_780p-1728.mp4</streamUrl>
</media>
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>1000</streamBitrate>
<streamUrl>http://dsoeehox1xjyp.cloudfront.net/roku/SHEPHERDS/video/7430_480p-928.mp4</streamUrl>
</media>
<synopsis>Current Series of Bible Studies - part 1</synopsis>
<genres>Bible Studies</genres>
<runtime>3600</runtime>
</item>
, and my Global Captions are enabled, and when I try to show caption tracks on my channel, it tells me there are no caption tracks available. Can someone please tell me what I am doing wrong?

Thanks!!
0 Kudos
4 REPLIES 4
belltown
Roku Guru

Re: Captions not Working

Are you calling EnableCaptions?
0 Kudos
srbsdean
Visitor

Re: Captions not Working

I believe I am. I started a new function on the appVideoScreen.brs doc called: "Function EnableCaptions(player as object) as void"

Is that what you mean?
0 Kudos
belltown
Roku Guru

Re: Captions not Working

"srbsdean" wrote:
I believe I am. I started a new function on the appVideoScreen.brs doc called: "Function EnableCaptions(player as object) as void"

Is that what you mean?

You've defined the function, but you actually have to call it for it to do anything.
0 Kudos
srbsdean
Visitor

Re: Captions not Working

Thank you for your assistance, I guess I am out of my league. I don't know how to do those types of things, if I can't find it them in an example. Do you have a sample or a script that you could show me?
0 Kudos