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: 
rsromeo
Channel Surfer

UNLOAD EVENT??

Hi -

I'm trying to do a URL transfer on video screen close because I want to update my db when stream stops. Problem is, it works when using up arrow to close video screen but when pressing HOME key on remote, the URL does not seem to get executed even though screen closes properly. I don't get a string back when app closes. Is there some kind of event I can use like unload to run code when app is closing?

thanks
0 Kudos
5 REPLIES 5
TheEndless
Channel Surfer

Re: UNLOAD EVENT??

Afraid not. Home kills the channel thread entirely. I have had sporadic success adding code at the end of the RunUserInterface() method that manages to get called sometimes, but it's not at all reliable.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
destruk
Streaming Star

Re: UNLOAD EVENT??

What you would "I think" have to do is to have your app poll your server at set intervals - and the server could log if the app polled on time or not. If the server didn't receive a request within a set timeframe from the roku client then the app would no longer be running.
0 Kudos
rsromeo
Channel Surfer

Re: UNLOAD EVENT??

Hmmm, seems like they should look into maybe creating an unload event. thanks guys!
0 Kudos
TheEndless
Channel Surfer

Re: UNLOAD EVENT??

"rsromeo" wrote:
Hmmm, seems like they should look into maybe creating an unload event. thanks guys!

There used to be one (well, at least the equivalent), but they changed the unload behavior back in 2.4 or 2.6 of the firmware. I believe the reasoning behind it had to do with the possibility of having bad code in the unload event that could hang the channel and/or the box. Ideally they could add it back with a timeout of a second or two to allow code to run while still having the ability to kill it if it went rogue.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
YungBlood
Streaming Star

Re: UNLOAD EVENT??

"destruk" wrote:
What you would "I think" have to do is to have your app poll your server at set intervals - and the server could log if the app polled on time or not. If the server didn't receive a request within a set timeframe from the roku client then the app would no longer be running.

I would do something simular to this. When the video starts, I would get the starting position, and send the contentid & position to the server, log the starting position, and have it give me a tracking ID. There is an event that triggers every few seconds while a video is playing to give you the position of the video. I would simply catch that event, and use an async http request to send the tracking ID & the latest position to the server. Then the server would log that position as the ending position. Each time the server gets a new position, it simply overwrites the last ending position. That gives you a rough idea of how much of the video was played, and where it started (useful for when people resume a video).

Or, a variation on that, just use timestamps. When the video starts, just log the content ID, and the starting time, and get back a tracking ID. Then with each position update, just log the new time for an ending time. Although you lose the position info, you get time played info. That will give you clues about how much people fast forwarded through the video.

--YB
YungBlood

Bringing more fun to Roku!
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.