nithyaak
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2014
12:21 PM
Mid roll video help
I managed to get the pre-roll video ad get played by following VAST example . I am currently trying to insert a mid roll ad. i can successfully launch mid roll (e.g. every 30 seconds in this testing below) however upon the mid roll finishes, its exiting the previous channel ( in this case live hls streaming) which I paused before i playing this mid roll and which makes to return to posterscreen. below is my code snip. hope somecan can shed some light what i am doing wrong here! ( I am using the SDK sample videoplayer to do this) .
in
in
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
5 REPLIES 5


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2014
04:55 PM
Re: Mid roll video help
There's only one video buffer. You can't pause one video, play another, then resume the first. You need to close your content video completely, play your ad, then re-open the content screen at the point you closed it by setting the playStart attribute.

RokuJoel
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2014
06:36 PM
Re: Mid roll video help
Hmm - not sure what is in your ShowMidroll function, but basically, try moving the canvas setup into its own function:
- Joel
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
- Joel
nithyaak
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2014
02:20 PM
Re: Mid roll video help
ShowMidroll function is as follows:
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
nithyaak
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2014
02:45 PM
Re: Mid roll video help
RokuJoel,
i tried your suggestion still not working. it exiting to PosterScreen 😞 after playing the ad.
thanks
i tried your suggestion still not working. it exiting to PosterScreen 😞 after playing the ad.
thanks

RokuJoel
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2014
01:54 PM
Re: Mid roll video help
Email me a copy of your channel jbraverman at roku dot com and if I have time I'll see if I can figure out what might be going on.
- Joel
- Joel