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

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 1
renojim
Community Streaming Expert

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
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.