Function showVideoScreen(episode As Object , index as Integer)
...
timer=createobject("rotimespan")
timer.mark()
while true
msg=screen.GetMessagePort().getmessage()
if type(msg) = "roVideoScreenEvent" then
'print "showVideoScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed()
print "appVideoScreen::showVideoScreen::Screen closed"
exit while
else if msg.isRequestFailed()
print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
else if msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()
else if msg.isButtonPressed()
print "appVideoScreen::showVideoScreen::Button pressed: "; msg.GetIndex(); " " msg.GetData()
else if msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
RegWrite(episode.ContentId, nowpos.toStr())
' print "isPlaybackPosition: "; nowpos
'mid roll...
if timer.totalmilliseconds() > 30000 then
print "inside timer block ...."
screen.SetGuidedTrickPlay(true)
screen.pause()
print "paused"
CanvasBlock=CreateObject("roImageCanvas")
CanvasBlock.SetLayer(0,"#000000")
CanvasBlock.Show()
if Showmidroll()
print "After playing midroll"
screen.Resume()
end If
timer.mark()
CanvasBlock.Close()
end If
else
' print "Unexpected event type: "; msg.GetType()
end if
else
'print "Unexpected message class: "; type(msg)
end if
end while
End Function
Function showVideoScreen(episode As Object , index as Integer)
...
timer=createobject("rotimespan")
timer.mark()
while true
msg=screen.GetMessagePort().getmessage()
if type(msg) = "roVideoScreenEvent" then
'print "showVideoScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed()
print "appVideoScreen::showVideoScreen::Screen closed"
exit while
else if msg.isRequestFailed()
print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
else if msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()
else if msg.isButtonPressed()
print "appVideoScreen::showVideoScreen::Button pressed: "; msg.GetIndex(); " " msg.GetData()
else if msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
RegWrite(episode.ContentId, nowpos.toStr())
' print "isPlaybackPosition: "; nowpos
'mid roll...
if timer.totalmilliseconds() > 30000 then
print "inside timer block ...."
screen.SetGuidedTrickPlay(true)
screen.pause()
print "paused"
If SetUpAdCanvas()
print "After playing midroll"
screen.Resume()
timer.mark()
end if
end If
else
' print "Unexpected event type: "; msg.GetType()
end if
else
'print "Unexpected message class: "; type(msg)
end if
end while
End Function
function setupADCanvas() as boolean
CanvasBlock=CreateObject("roImageCanvas")
CanvasBlock.SetLayer(0,"#000000")
CanvasBlock.Show()
result =showmidroll()
canvas.close()
return result
end function
Function ShowMidRoll(video) As Boolean
' a true result indicates that playback finished without user intervention
' a false result indicates that the user pressed UP or BACK to terminate playback
Result=True
CanvasMidRoll=CreateObject("roImageCanvas")
PlayerMidRoll=CreateObject("roVideoPlayer")
Port=CreateObject("roMessagePort")
CanvasMidRoll.SetMessagePort(Port)
' build a very simple buffer screen for our MidRoll video
CanvasMidRoll.SetLayer(0, { text: "Your program will begin after this message" })
CanvasMidRoll.Show()
' be sure to use the same message port for both the canvas and the player
' so we can receive events from both
PlayerMidRoll.SetMessagePort(Port)
PlayerMidRoll.SetDestinationRect(CanvasMidRoll.GetCanvasRect())
PlayerMidRoll.AddContent(video)
PlayerMidRoll.Play()
' start our event loop
While True
' wait for an event
msg=Wait(0, CanvasMidRoll.GetMessagePort())
If Type(msg)="roVideoPlayerEvent"
If msg.isFullResult()
' the video played to the end without user intervention
Exit While
Else If msg.isRequestFailed()
' something went wrong with playback, but the user did not intervene
Exit While
Else If msg.isStatusMessage()
If msg.GetMessage()="start of play"
' once the video starts, clear out the canvas so it doesn't cover the video
CanvasMidRoll.SetLayer(0, { color: "#00000000", CompositionMode: "Source" })
CanvasMidRoll.Show()
End If
End If
Else If type(msg)="roImageCanvasEvent"
If msg.isRemoteKeyPressed()
index=msg.GetIndex()
If index=0 Or index=2
' the user pressed UP or BACK to terminate playback
Result=False
Exit While
End If
End If
End If
End While
PlayerMidRoll.Stop()
CanvasMidRoll.Close()
Return Result
End Function