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

End Channel every # of days.

Hello Guys,

I was wondering how can i use the END command to End channel every # of days.It will be great if anyone can share a line of code 🙂

Cheers.
0 Kudos
1 REPLY 1
jbrave
Channel Surfer

Re: End Channel every # of days.

at start of your program, create a global timer variable, for example:

m.timer=createobject("rotimespan")
m.timer.mark()
m.days=5


There are various ways to implement the above, for instance, if you are using a more object oriented approach to your programming, you may want to include the timer in a global object that you create at start time:

function init() as object
return {timer:createobject("rotimespan")
days:5}
end function

You might have a function that checks the time, which you can call from within all parts of your application, for example:

function timecheck()
if m.timer.totalseconds() > (m.numdays * 86400)
dialog=createobject("roonelinedialog")
dialog.settitle("time's up!")
dialog.show()
sleep(10000)
dialog.close()
end
end if
end function


To do this you will need to make sure all your msg=wait(time,port) statements do not block, in otherwords, use values greater than 0: for example:


while true
msg=wait(100,port)
timecheck()
end while
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for 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.