Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
salman23
Level 7

videoscreen flashes and disappears

Hi,
I have a channel containing two screens posterscreen and rovideoscreen.What i want to do is,when i click the poster item,i need to go to videoscreen.But what happens is that , the videoscreen just appear and suddenly disappears.And in debug output,it prints the message "screen closed" in iscreenclosed() function. but when i run the videoscreen alone ,it works properly.Can anyone help please.?

poster.brs

Function showPosterScreen() As Integer
poster=CreateObject("roPosterScreen")
port=CreateObject("roMessagePort")
poster.SetMessagePort(port)
poster.SetListStyle("arced-landscape")
poster.SetContentList(showList = [
{
ShortDescriptionLine1:"Show #1",
ShortDescriptionLine2:"Short Description for Show #1",
}
{
ShortDescriptionLine1:"Show #2",
ShortDescriptionLine2:"Short Description for Show #2",
}
{
ShortDescriptionLine1:"Show #3",
ShortDescriptionLine2:"Short Description for Show #3",
}
])
poster.Show()

while true
msg = wait(0,port)
if type(msg) = "roPosterScreenEvent" then
print "showPosterScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isListFocused() then
print "focusing"
else if msg.isListItemSelected() then
VideoPlayer()
else if msg.isScreenClosed() then
return -1
end if
end If
end while
End Function


videoscreen.brs

Function VideoPlayer() As void
port = CreateObject("roMessagePort")
screen = CreateObject("roVideoScreen")
screen.SetMessagePort(port)
screen.SetPositionNotificationPeriod(3)
metaData={
Stream: { url: "http://video.ted.com/talks/podcast/JeffHan_2006_480.mp4" }
StreamFormat: "mp4"
}
screen.SetContent(metaData)
screen.Show()

while true
msg = wait(0, port)
if type(msg) = "roVideoScreenEvent" then
print "showHomeScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isStreamStarted()
print "started playing"
else 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
else if msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
end if
else
print "Unexpected message class: "; type(msg)
end if
end while
End Function
0 Kudos
1 Reply
renojim
Level 8

Re: videoscreen flashes and disappears

I'm not sure how you ever got to VideoPlayer(). This line isn't valid BrightScript (or at least not how you're intending for it to act; I believe it's doing a Boolean comparison and I get a runtime error of an uninitialized variable):
poster.SetContentList(showList = [
{
ShortDescriptionLine1:"Show #1",
ShortDescriptionLine2:"Short Description for Show #1",
}
{
ShortDescriptionLine1:"Show #2",
ShortDescriptionLine2:"Short Description for Show #2",
}
{
ShortDescriptionLine1:"Show #3",
ShortDescriptionLine2:"Short Description for Show #3",
}
])

Either get rid of the "showlist =" or split it out on its own line:
showList = [
{
ShortDescriptionLine1:"Show #1",
ShortDescriptionLine2:"Short Description for Show #1",
}
{
ShortDescriptionLine1:"Show #2",
ShortDescriptionLine2:"Short Description for Show #2",
}
{
ShortDescriptionLine1:"Show #3",
ShortDescriptionLine2:"Short Description for Show #3",
}
]
poster.SetContentList(showList)

-JT
0 Kudos