I’m wondering if it’s possible to detect if a screen has been closed?
In one function, it’s possible that a screen I’m working with would have been closed. Once that method exits, additional code runs that may need to execute a different path depending on if that screen was closed or not. In this case, I can’t simply go by the return value of that first method.
I tried checking that object to see if it is = invalid, but that doesn’t work.
Any ideas? Thanks
You need to check for the msg.isScreenClosed() event:
while true
msg=wait(0,port)
if lcase(type(msg))=lcase("name of screentypemessage goes here") then
if msg.isScreenClosed() then
return "Screen Closed"
else if <some other condition> then
print "do something else"
end if
end if
end while
Can you confirm that during a connection loss, there’s nothing I can do to prevent the Roku from kicking back to the main screen?
If your channel is kicking back to the main screen, that means that some value is not what is expected in your code. You can check if the value is the correct type or is invalid before doing a comparison or using a variable, for example if you are expecting an roXMLElement you can check first:
if myvar <> invalid and lcase(type(myvar))="roxmlelement" then
doSomeProcess(myvar)
else
handleTheError(myvar)
end if
otherwise, your channel will probably crash when the value is not what is expected, and in a published channel, a crash takes you back to the main screen.
I wouldn’t necessarily say this is a crash - as Roku pops up a message indicating there was a network connectivity loss, and prompts to being me into the network settings. If it was just a normal crash, I don’t think that would happen. I tried by playing a VOD HLS stream and disconnecting the ethernet cable. Then it played out all it had, and I assume when it reached the end and couldn’t download anymore it triggered something in the Roku to do that.
Do you have any recommends for debugging this - normally I telnet into the Roku to see debug output. However during a network loss I lose the telnet session and debug output.
Ah, that. No there isn’t any way to detect that in your channel.
Do you know why you are losing your network connection, or is it somehow triggered from within your channel? If it is, can you reproduce the situation where it occurs?
Thanks. I’m doing it on purpose to see how the app reacts to a loss of network connectivity. I was experimenting with creating an app that could stream something 24/7 and “restart” itself in case of a network failure. I suppose that is not possible.