Thanks for the help and the suggestion, but that still didn't work for me. Your suggestion caused the app to exit from the video screen not long after the loading animation appeared and then the pop up would show up over the main screen instead of the playing video.
However, I was able to keep playing around with it and below is the code that I now have working. I think I may be completely misunderstanding the stack concept, but I completely left that behind and took a more object oriented approach to the situation. Now I have a working model that I can build on.
Thanks to everyone for their help and suggestions through this.
Sub Main()
Console_Log("Creating the global variables")
m.popup_time = 10000
m.close_time = 30000
m.port = CreateObject("roMessagePort")
temp = Show_Main_Screen()
temp.Show()
video = Show_Video_Screen()
Main_Timer(video)
while true
msg = wait(0, temp.GetMessagePort())
if type(msg) = "roParagraphScreenEvent"
if msg.isScreenClosed()
exit while
'if you want to play again
else if msg.isButtonPressed()
if msg.GetIndex() = 0
video = Show_Video_Screen()
Main_Timer(video)
else if msg.GetIndex() = 1
temp.Close()
exit while
end if
end if
end if
end while
End Sub
Function Show_Main_Screen() As Object
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.AddButton(0, "Play Again")
screen.AddButton(1, "Exit")
Console_Log("Main Screen Shown")
return screen
End Function
Function Show_Video_Screen() As Object
video = CreateObject("roVideoScreen")
video.SetContent({
Title: "Test Video For Timer Functionality"
StreamFormat: "mp4"
Stream: {
URL: "http://video.mp4"
}
})
Console_Log("Video Screen Shown")
return video
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
Sub Main_Timer(video as object)
Console_Log("Main Timer Started")
timer=createObject("rotimespan")
port = CreateObject("roMessagePort")
timer.Mark()
video.Show()
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("The 'Yes' Button Was Pressed")
timer.Mark()
else if (response = false)
Console_Log("The 'No' Button Was Pressed")
video.Close()
exit while
end if
end if
end if
end while
End Sub
Function Console_Log(Message)
print Message
End Function
שלום חבר
Dean at the School of Truth: a part of Autodidact University.
"A programmer is just a tool which converts caffeine into code"
Temet nosce
Vi Veri Veniversum Vivus Vici
Si vis pacem, para bellum