Function showVideoScreen(episode As Object)
If Type(episode)<>"roAssociativeArray"
Print"invalid data passed to showVideoScreen"
Return -1
End If
AdStatus=TRUE
'create another facade screen to prevent flicker
canvas=CreateObject("roImageCanvas")
canvas.SetLayer(0,{Color:"#FF000000",CompositionMode:"Source"})
canvas.Show() 'show the screen
If Episode.PrePlay1<>""
port=CreateObject("roMessagePort")
screen=CreateObject("roVideoScreen")
screen.SetMessagePort(port)
screen.SetPositionNotificationPeriod(30)
ContentToPlay=CreateObject("roAssociativeArray")
ContentToPlay.Title="Video will play after this message"
ContentToPlay.ContentType="movie"
ContentToPlay.StreamFormat="mp4"
ContentToPlay.ContentQuality="SD"
ContentToPlay.StreamQualities=[]
ContentToPlay.StreamBitrates=[]
ContentToPlay.StreamUrls=[]
ContentToPlay.StreamQualities.Push("SD")
ContentToPlay.StreamBitrates.Push(0)
ContentToPlay.StreamUrls.Push(episode.PrePlay1)
screen.SetContent(ContentToPlay)
screen.show()
While TRUE
msg=wait(0,port)
If Type(msg)="roVideoScreenEvent"
Print"showHomeScreen | msg = ";msg.getMessage();" | index = ";msg.GetIndex()
If msg.isScreenClosed()
Print"Screen closed"
Exit While
ElseIf msg.isRequestFailed()
Print"Video request failure: ";msg.GetIndex();" ";msg.GetData()
Exit While
' ElseIf msg.isPartialResult() 'user quit before video finished playing
' AdStatus=FALSE
ElseIf msg.isStatusMessage()
Print"Video status: ";msg.GetIndex();" ";msg.GetData()
ElseIf msg.isButtonPressed()
Print"Button pressed: ";msg.GetIndex();" ";msg.GetData()
Else
Print"Unexpected event type: ";msg.GetType()
End If
Else
Print"Unexpected message class: ";type(msg)
End If
End While
screen.close()
End If
If AdStatus=TRUE
port=CreateObject("roMessagePort")
screen=CreateObject("roVideoScreen")
screen.SetMessagePort(port)
screen.SetPositionNotificationPeriod(30)
screen.SetContent(episode)
screen.Show()
'Uncomment this 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 If
canvas.Close() 'ensure facade screen is destroyed
End Function
We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. Read more here.
Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 19th and you may notice reduced functionality.
In the meantime, for additional assistance, visit our Support Site.
We're sorry for this disruption — we’re excited to share what’s next!