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

Pre-Roll I need a way to not accept a button press

Hello,

I have a Pre-Roll set in videoplayer that uses xml to read the preroll line. I cannot seem to get the Pre-Roll video to not accept a Button press. I want the pre-roll to play until done no matter what button is pressed except Home, then allow the content to play as usual with button presses. I know roVideoPlayer disables trickmode or button presses, but I can't seem to get it working. I will attach my appVideoScreen.brs here for anyone that has some input to make it work. My pre-roll plays now and if I press the Up arrow on remote it goes to the content. Reply here or PM me
'**********************************************************
'** Video Player Example Application - Video Playback
'** November 2009
'** Copyright (c) 2009 Roku Inc. All Rights Reserved.
'**********************************************************

'***********************************************************
'** Create and show the video screen. The video screen is
'** a special full screen video playback component. It
'** handles most of the keypresses automatically and our
'** job is primarily to make sure it has the correct data
'** at startup. We will receive event back on progress and
'** error conditions so it's important to monitor these to
'** understand what's going on, especially in the case of errors
'***********************************************************
Function showVideoScreen(episode As Object)

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

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

If Episode.PrePlay<>""

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

ContentToPlay=CreateObject("roAssociativeArray")
ContentToPlay.Title="The show 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.PrePlay)
screen.SetContent(ContentToPlay)
screen.show()
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
screen.close()
End if
port=CreateObject("roMessagePort")
screen=CreateObject("roVideoScreen")
screen.SetMessagePort(port)
screen.SetPositionNotificationPeriod(30)
screen.SetContent(episode)
screen.Show()

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

0 Kudos
4 REPLIES 4
RokuChris
Roku Employee
Roku Employee

Re: Pre-Roll I need a way to not accept a button press

If you use roVideoScreen to play your preroll, you won't be able to ignore the UP or BACK buttons. You need to use roVideoPlayer to accomplish that. There are a couple blog posts that should help with that:

http://blog.roku.com/developer/2011/06/ ... r-channel/
http://blog.roku.com/developer/2012/10/ ... eo-player/
0 Kudos
bandal
Visitor

Re: Pre-Roll I need a way to not accept a button press

Chris,
I have seen both and can't seem to get it going in my code all day yesterday. I have tried many times and no luck. That is why I asked for more help looking at what I have so far in my .brs file. Any takers? I am not so great at programming, but trying.
Thanks,
0 Kudos
TheEndless
Channel Surfer

Re: Pre-Roll I need a way to not accept a button press

As Chris pointed out, you can't prevent key pressed on the roVideoScreen. You need to use an roVideoPlayer for the pre-roll. The code you posted only has roVideoScreens in it.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
bandal
Visitor

Re: Pre-Roll I need a way to not accept a button press

Yes, the code posted is what I was testing with and I tried the roVideoPlayer and got too many errors, I also changed the msg. part as seen in the preroll blogs and no luck, so I backed off to original to show what I started with. Thinking maybe someone can take it and modify it to work.
0 Kudos