DukeOfMarshall
11 years agoVisitor
Stack Not Working, Exits App
My attempt here is to create a player with a live video stream and confirm the viewer is still watching after a predetermined time. Currently I have the video playing and a confirmation dialog pop up. If a viewer confirms they are still watching then the timer loop resets and repeats as necessary.
The issue I'm running into is that if the viewer does not confirm they are still watching or clicks no, then the app completely exits back to the main Roku screen. From my understanding, since I am creating the paragraph screen before the video screen, then the screens are stacked and if the video screen is closed, then in theory it should return to the previous screen in the stack. But it's not doing this.
Am I misunderstanding the use of stacked screens or is there something wrong with my code?
Thanks.
The issue I'm running into is that if the viewer does not confirm they are still watching or clicks no, then the app completely exits back to the main Roku screen. From my understanding, since I am creating the paragraph screen before the video screen, then the screens are stacked and if the video screen is closed, then in theory it should return to the previous screen in the stack. But it's not doing this.
Am I misunderstanding the use of stacked screens or is there something wrong with my code?
Thanks.
Function Main()
Console_Log("Creating the global variables")
m.popup_time = 10000
m.close_time = 30000
m.port = CreateObject("roMessagePort")
Show_Main_Screen()
video = CreateObject("roVideoScreen")
video.SetContent({
Title: "Test Video For Timer Functionality"
StreamFormat: "mp4"
Stream: { URL: "http://video.mp4"}
})
video.Show()
Console_Log("Video Screen Shown")
Main_Timer()
End Function
Function Show_Main_Screen()
screen = CreateObject("roParagraphScreen")
screen.SetMessagePort(m.port) ' instruct screen to send events to port
screen.AddParagraph("Just a test screen for a timer function")
screen.Show()
Console_Log("Main Screen Shown")
End Function
Function Show_Popup() as Boolean
Console_Log("Starting Popup Function")
newport = CreateObject("roMessagePort")
popup = CreateObject("roMessageDialog")
popup.SetMessagePort(newport) ' instruct screen to send events to port
popup.SetTitle("Viewer")
popup.SetText("Are you still watching?")
popup.AddButton(0, "Yes")
popup.AddButton(1, "No")
popup.Show()
Console_Log("Popup Shown")
timer=createObject("rotimespan")
timer.Mark()
while true
msg = wait(5000, popup.GetMessagePort())
if type(msg) = "roMessageDialogEvent"
if msg.isButtonPressed()
if msg.GetIndex() = 0
popup.Close()
return true
exit while
else if msg.GetIndex() = 1
popup.Close()
exit while
end if
end if
end if
return false
end while
End Function
Function Main_Timer()
Console_Log("Main Timer Started")
timer=createObject("rotimespan")
port = CreateObject("roMessagePort")
timer.Mark()
while true
event = port.GetMessage()
if(event = invalid)
ticks = timer.TotalMilliseconds()
if(ticks > m.popup_time AND ticks < (m.popup_time+2000))
print Stri(m.popup_time+2000)
response = Show_Popup()
if (response = true)
Console_Log("Yes Button Was Pressed")
timer.Mark()
else if (response = false)
Console_Log("No Button Was Pressed")
exit while
end if
end if
end if
end while
End Function
Function Console_Log(Message)
print Message
End Function