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

roSGScreenEvent never firing?

Hello,

I need to detect when someone closes the screen before the channel exits completely.  Per this documentation, it looks like I should be getting an isScreenClosed event.  

https://sdkdocs.roku.com/display/sdkdoc/roSGScreenEvent

But it never arrives.  Does everyone else see the same?  I even checked out some sample channels, such as this one:

https://github.com/rokudev/videoplayer-channel

And yet when I hit the back button, no event is detected. I added the print statement in the snippet below from the Main function, and it is never executed.  Any ideas?

  while(true)
    msg = wait(0, m.port)
        msgType = type(msg)
        Print "we got it!!"
        If msgType = "roSGScreenEvent"Then
      if msg.isScreenClosed() then return
    end if
  end while
end sub
0 Kudos
3 REPLIES 3
roquoonewbie
Visitor

Re: roSGScreenEvent never firing?

Nobody has any input on this?
0 Kudos
NB_
Roku Guru

Re: roSGScreenEvent never firing?

you will get roSGScreenEvent if the roSgScreen in question was closed by pressing Back button or programmatically. If however Home button was pressed, the app is terminated immediately - currently there is no event hook you can use to detect impending exit. As alternative, you could periodically save state/progress to registry or cloud service.
roquoonewbie
Visitor

Re: roSGScreenEvent never firing?

RokuNB, my post was concerning the Back button.  Using the sample, there is no  msg.isScreenClosed() event detected.. It is easily reproduceable using the posted sample and you should see the same. Do you not?

Regarding your Home button statement, why is that the case?  It seems like Roku is going backward with scenegraph.  On the old SDK, if a video was playing and the user pressed the home button, two different events were fired (msg.isPartialResult() and msg.isScreenClosed() ).  Why would Roku remove the ability to detect this event in the scene graph sdk?

How is a channel supposed to send an event to (for example) a mobile controller/casting app to tell it that it is exiting the video play process (so the mobile app can update the play state on it's screen)?  This seems like a critical feature that has been removed...but why?
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.