"destruk" wrote:
Maybe you need to check for a playback failure and then clear the caption for the failed video. Or rather than feeding it an entire content playlist, feed it one caption and one video at a time until the list is completed.
Function engagelooping()
conn=CreateObject("roAssociativeArray")
conn.UrlCategoryFeed="http://server/looping.xml"
conn.LoadCategoryFeed=load_show_feed
Categories=conn.LoadCategoryFeed(conn)
list=CreateObject("roArray",1,TRUE)
For i=0 to (Categories.Kids.Count()-1) 'this will need to be adjusted to fit your feed xml schema
list.Push(Categories.kids[i])
Next
rcanvas=CreateObject("roImageCanvas") 'create black screen to hide the springboard when any video ends and starts playing next video
rcanvas.show()
inz=-1 'initialize single counter for single video in list
checking:
inz=inz+1 'increment counter
if inz=list.count() inz=0 'reset counter to loop list
result=ShowVideoScreenLOOP(list[inz]) 'send current single video item to video player
if result=0 goto checking 'loop back to checking routine
rcanvas.close() 'loop is finished, so close canvas mask
End Function
"destruk" wrote:
To check for playback failure, in your wait routine in the video player section in Brightscript, add an If msg.isRequestFailed() Then
isRequestFailed() as Boolean
Video playback has failed.
GetMessage() as String
Returns text description of error.
GetIndex() as Integer
Returns one of the following error IDs:
0 Network error : server down or unresponsive, server is unreachable, network setup problem on the client.
-1 HTTP error: malformed headers or HTTP error result.
-2 Connection timed out
-3 Unknown error
-4 Empty list; no streams were specified to play
-5 Media error; the media format is unknown or unsupported
http://sdkdocs.roku.com/display/sdkdoc/ ... layerEvent
For feeding it one item to play at a time - use a simple loop before calling videoplayer -
such as...
in the springboard screen where you have your wait loop for the springboard screen -
iSelected=0
If msg.isListItemSelected()
iSelected=msg.GetIndex()
Currentkid=Categories.Kids[iSelected]
If UCASE(Currentkid.title)="LOOP" Then EngageLooping()
Function engagelooping()
conn=CreateObject("roAssociativeArray")
conn.UrlCategoryFeed="http://server/looping.xml"
conn.LoadCategoryFeed=load_show_feed
Categories=conn.LoadCategoryFeed(conn)
list=CreateObject("roArray",1,TRUE)
For i=0 to (Categories.Kids.Count()-1) 'this will need to be adjusted to fit your feed xml schema
list.Push(Categories.kids[i])
Next
rcanvas=CreateObject("roImageCanvas") 'create black screen to hide the springboard when any video ends and starts playing next video
rcanvas.show()
inz=-1 'initialize single counter for single video in list
checking:
inz=inz+1 'increment counter
if inz=list.count() inz=0 'reset counter to loop list
result=ShowVideoScreenLOOP(list[inz]) 'send current single video item to video player
if result=0 goto checking 'loop back to checking routine
rcanvas.close() 'loop is finished, so close canvas mask
End Function
Referring back to checking for failure - as long as your video player function returns 0 in this case, it will loop to the next video endlessly until Home is pressed.
If your video fails, or the user presses UP to cancel playback, you should have it return something other than 0. And you can check the return values to see what happened where it says if result=0
So if result=1 then they press up and you should close the screen (for instance)
Finally, yes, if it is a confirmed bug in the roVideoPlayer component itself, then Roku should file a bug and fix it themselves -- not having seen any of your code you are using, it sounds like it's probably not replacing the SRT for the appropriate piece of content somewhere - whether that is in your code or the component yourself I don't have tools to test that as I haven't ever used SRT files myself - we prefer to burn subtitles overlaid into a separate video file so we don't need to deal with it.
videoList = CreateObject("roArray", 1, true)
for each vid in json.videos
video = CreateObject("roAssociativeArray")
video.title = vid.title
video.streamFormat = vid.type
video.stream = CreateObject("roAssociativeArray")
video.stream.url = vid.url
video.stream.bitrate = 1500
video.stream.quality = true
video.stream.contentId = vid.content_id
video.subtitleUrl = vid.subtitle_url
videoList.Push(video)
end for
video = CreateObject("roAssociativeArray")
video.title = vid.title
video.streamFormat = vid.type
video.stream = CreateObject("roAssociativeArray")
video.stream.url = invalid
video.stream.bitrate = 1500
video.stream.quality = true
video.stream.contentId = vid.content_id
video.subtitleUrl = vid.subtitle_url
videoPlayer.SetMessagePort(port)
videoPlayer.SetDestinationRect(playerRect)
videoPlayer.SetPositionNotificationPeriod(1)
videoPlayer.SetMaxVideoDecodeResolution(1920, 1080)
videoPlayer.SetLoop(false)
captions = videoPlayer.GetCaptionRenderer()
captions.SetMode(2)
captions.SetMessagePort(port)
captions.ShowSubtitle(true)
videoPlayer.SetCertificatesFile("common:/certs/ca-bundle.crt")
videoPlayer.SetCertificatesDepth(4)
videoPlayer.InitClientCertificates()
videoPlayer.SetContentList(videoList)
while true
msg = wait(0, m.port)
if msg <> invalid
if type(msg) = "roCaptionRendererEvent"
if msg.isCaptionText()
caption = msg.GetMessage()
m.captionTextList = caption.Tokenize(chr(10)) ' char(10) is newline
end if
end if
if type(msg) = "roUniversalControlEvent"
' http://sdkdocs.roku.com/display/sdkdoc/roUniversalControlEvent
if msg.GetInt() = 0 'back button is pressed
return 1
else if msg.GetInt() = 10 'info/* button is pressed
m.videoPlayer.Pause()
m.screen = invalid
userChoice = m.showOptionsDialog()
if userChoice = 0
return 3
else if userChoice = 1
return 4
end if
m.screen = CreateObject("roScreen", true)
m.screen.SetMessagePort(m.port)
m.screen.SetAlphaEnable(true)
m.videoPlayer.Resume()
end if
else if type(msg) = "roVideoPlayerEvent"
if msg.GetMessage() = "start of play" OR msg.isPlaybackPosition()
if m.isLoadingVideo = true
m.isLoadingVideo = false
m.drawScreen()
end if
else if msg.GetMessage() = "startup progress"
if m.isLoadingVideo <> true
m.isLoadingVideo = true
m.drawScreen()
end if
else if msg.GetMessage() = "Playback completed."
return 2
end if
end if
end if
end while
currentvideo=0 'initialize counter -- maybe this isn't necessary but it is here for legibility so I know later it will be an integer and what it is used for
....event loop....
else if type(msg) = "roVideoPlayerEvent"
If msg.isrequestfailed()
errormessage=msg.info()
playlist=videoPlayer.GetContentList()
for x=0 to playlist.count()-1
If errormessage.url=playlist[X].stream.url then 'once bad stream has been found, no need to search for it so break out of the for loop
currentvideo=X
exit for
end if
next
for x=0 to currentvideo 'it failed so delete everything that has already played as well as current video that tried to play
playlist.delete[X]
next
if playlist.count()>0 'if there are items left to play
videoPlayer.SetContentList(playlist)
videoPlayer.Show() 'might not be necessary, but show the screen again to restart the videos with the altered new playlist
end if
end if
"destruk" wrote:
I would think something like this would work for your situation, still using the playlist -
I haven't tested it but the logic makes sense to me.
currentvideo=0 goes before your event loop starts for the video player (in the video player routine)
The code in the event loop goes into your event loop for the video player routine.
currentvideo=0 'initialize counter -- maybe this isn't necessary but it is here for legibility so I know later it will be an integer and what it is used for
....event loop....
else if type(msg) = "roVideoPlayerEvent"
If msg.isrequestfailed()
errormessage=msg.info()
playlist=videoPlayer.GetContentList()
for x=0 to playlist.count()-1
If errormessage.url=playlist[X].stream.url then 'once bad stream has been found, no need to search for it so break out of the for loop
currentvideo=X
exit for
end if
next
for x=0 to currentvideo 'it failed so delete everything that has already played as well as current video that tried to play
playlist.delete[X]
next
if playlist.count()>0 'if there are items left to play
videoPlayer.SetContentList(playlist)
videoPlayer.Show() 'might not be necessary, but show the screen again to restart the videos with the altered new playlist
end if
end if
"destruk" wrote:
If you need it to loop (always something, right?) then rather than deleting everything up to the point of failure in the playlist, you could remove just the failed item, track what item was removed, and reset the playlist followed by SetNext to restart where it left off with the next piece of valid content.
http://sdkdocs.roku.com/display/sdkdoc/ ... egerasVoid
SetNext(item as Integer) as Void
Set what the next item to be played within the Content List should be.
I'd still recommend deleting the entire piece of bad content so the number of subtitle urls that are valid will match up with the number of valid video urls - as that seems to be the problem for the rovideoplayer/rocaption