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

want to put url of video into different files

Hi,
Is it possible to put the video urls into different xml instead of putting all urls in single file as given in the example?
2)Any code to automacally logout if there is more than 2 hours of inactivity with a message?
0 Kudos
3 REPLIES 3
RokuJoel
Binge Watcher

Re: want to put url of video into different files

You can do it any way you want as long as you are creating valid XML. You can have a file for each video for example and retrieve it at playback time. The more separate files you have, the more of a bandwidth and CPU hit on your servers will be subject due to multiple retrieval requests, so might be best to have just one or two.

Of course you need to have at least one xml file that specifies where all the other files can be found.

For the Log Out:

You could set up a timer with rotimespan:

m.timer=createobject("roTimeSpan")


and then in every function in your channel make sure that the wait time is non zero, and, you can exit the channel when 2 hours completes:

while true
msg=wait(100,port)
if m.timer.totalseconds > 3600 then
dialog=createobject("roOneLineDialog")
Dialog.settitle("You have been logged out due to inactivity")
end
end if
if msg <> invalid then
'reset the timer on any activity
m.timer.mark()
end if


You would probably want to make it a bit more elaborate than that but hopefully that gets you the gist of it.

- Joel
0 Kudos
learner
Channel Surfer

Re: want to put url of video into different files

hi, Joel
i would like to have th eminimum load on CPU but the problem is if i change the url
the urls on the applications is not updated if the user doesnt go out of the app and then the xml
gets updated
Any timeout for the xml or any other way to refresh the xml or exit the application when an update is given?
0 Kudos
RokuJoel
Binge Watcher

Re: want to put url of video into different files

yeah, you can refresh your XMl just the way I suggested forcing the channel to quit. For example, say you are on a PosterScreen:


sub main()
m.timer=createobject("roTimeSpan")
m.refreshtimer=createobject("roTimeSpan")
m.timer.mark()
m.refreshtimer.mark()
showposterscreen()
end sub

function showposterscreen()
data=getMyDataFromMyServer()
port=createobject("romessageport")
screen=createobject("roPosterScreen")
screen.setcontentlist(data)
screen.setport("port")
screen.show()
while true
if refreshtimer.totalseconds() > 3600 then
data=getMyDataFromMyServer()
screen.setcontentlist([])
screen.setcontentlist(data)
screen.setfocusedlistitem(0)
refreshtimer.mark()
end if

msg=wait(100,port)

if type(msg)="roPosterScreenEvent" then
if msg.islistitemselected() then
ndx=msg.getindex()
showspringboardscreen(data[ndx])
else if msg.isscreenclosed()
return -1
end if
end if
end while
end function

function getMyDataFromMyServer() as object
url="http://myserver.com/mydata/data.xml"
xfer=createobject("roURLTransfer")
xfer.seturl(url)
xmldata=xfer.gettostring()
data=parseMyXML(xmldata)
return data
end function


of course you have to use your own xml parser that you are currently using. The crucial thing here is you never use msg=wait(0,port) because that function will just sit there forever till someone hits a key, thus msg=wait(100,port) will only wait for 100milliseconds before checking if the timer has reached > 1 hour and if so, refresh the data.

- Joel
0 Kudos