Your Digital Media Has Never Looked So Good

 
bosborne
Topic Author
Posts: 141
Joined: Wed Jun 06, 2012 10:42 am

Check if screen has been closed?

Wed Jun 27, 2012 10:22 am

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
 
User avatar
RokuJoel
Posts: 1758
Joined: Mon Nov 14, 2011 5:22 pm

Re: Check if screen has been closed?

Wed Jun 27, 2012 12:54 pm

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
 
bosborne
Topic Author
Posts: 141
Joined: Wed Jun 06, 2012 10:42 am

Re: Check if screen has been closed?

Tue Dec 11, 2012 6:47 pm

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?
 
User avatar
RokuJoel
Posts: 1758
Joined: Mon Nov 14, 2011 5:22 pm

Re: Check if screen has been closed?

Wed Dec 12, 2012 11:20 am

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.

- Joel
 
bosborne
Topic Author
Posts: 141
Joined: Wed Jun 06, 2012 10:42 am

Re: Check if screen has been closed?

Thu Dec 13, 2012 6:34 am

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.
 
User avatar
RokuJoel
Posts: 1758
Joined: Mon Nov 14, 2011 5:22 pm

Re: Check if screen has been closed?

Thu Dec 13, 2012 12:27 pm

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?

- Joel
 
bosborne
Topic Author
Posts: 141
Joined: Wed Jun 06, 2012 10:42 am

Re: Check if screen has been closed?

Sat Dec 15, 2012 5:52 pm

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.

Who is online

Users browsing this forum: No registered users and 9 guests