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: 

Cleanup tasks using roRegistrySection

Currently there is no provision in brightscript to perform cleanup tasks when the application is closed, however some of the tasks need to be performed at a highest priority.
While integrating a channel (that plays videos) with google analytics, I want to track the amount of time for which a particular video has been played, for which need to fire an event as soon as the channel is stopped.
However, it seems impossible to track the app close event, (with reference to previous topics based , it was possible in firmware 3.1). Currently thinking of writing time for which a video was played into roRegistrySection, reading the contents back from the registry section while the next time app is started again to see for what time the video was played.

the pseudo code (not the actual snippet) goes like this :


while the app starts
check the registry for the cleanup flag ' cleanup flag is the flag which if set, the google analytics event relating to the video play time was not fired
if the flag is set
read the time for which the video was played from the registry
fire the event
else continue with the regular activities


I do not see a reason why the above pseudo code will not work.
However, the performance onus to log the time into the registry for the step read the time for which the video was played from the registry would have tremendous performance onus.
I want the precision to be of one second, for which I will have to write to registry modifying the 'time played ' key for every second of video played. With reference to " Flushing the registry is a relatively time-consuming operation, so it should be done as infrequently as possible." over http://sdkdocs.roku.com/display/sdkdoc/roRegistrySection , this could be a disaster.

The app would be snail slow if I keep flushing the registry every second of video played.
Is registry_section.write() inexpensive compared to registry_section.flush() ? and is registry_section.flush() automatically called when the app is closed ? if that is the case, the above approach might work.
Any help would be greatly appreciated.
-Batheja Sumeet
0 Kudos
5 REPLIES 5
TheEndless
Channel Surfer

Re: Cleanup tasks using roRegistrySection

"bathejasumeet" wrote:
with reference to previous topics based , it was possible in firmware 3.1

No.. it was possible in version 2.4, I believe.. removed in 2.6. That was 4 or 5 years ago.

Why not setup beacon event to GA instead, so you record every 5-10 seconds of play as separate events, then you can add them all together to get your total. Why do you need a precision of one second? That seems excessive.
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

Re: Cleanup tasks using roRegistrySection

Hi endless,
certain videos span 15-20 minutes, certain span hours. Beacon per 10 seconds of video will fire 60 events per 10 minutes per user, which is too high.
For an hour of video, it would lead to 360 events per user, assuming the channel is going to go live over the world, the events would grow at an exponential rate, even the filtering logic processing on the GA server would be heavy.
So I think beacon would be a bad idea.
0 Kudos

Re: Cleanup tasks using roRegistrySection

how is that relevant to the question?
0 Kudos
belltown
Roku Guru

Re: Cleanup tasks using roRegistrySection

"bathejasumeet" wrote:
The app would be snail slow if I keep flushing the registry every second of video played.

Really? I doubt it.

I ran a quick test on my antique Roku HD running the 3.1 firmware. It was easily able to handle to a Read Registry/Write Registry/Flush Registry sequence using a 1000+ character key value, at a rate of 10 times per second, while simultaneously playing an HD HLS video stream. It also appears to flush the registry when the channel closes. If your testing shows otherwise then I'd be curious to know what else your channel is doing while playing the video.
0 Kudos

Re: Cleanup tasks using roRegistrySection

Hi,
I am currently working on framework version 6.1, whatever I claimed was with reference to the docs of roRegistry mentioned in my previous comment., if that works fine for framework v6.1, I think it would be very much apt for my situaton, thanks belltown , will run the tests on v6.1 and let you know
-bathejasumeet 😄
0 Kudos