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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Channel Surfer

Re: Is there a way to execute a function every few secs


I have changed background image in .brs file in task node folder but it is not updated. 

I need to change the background image in .brs file in task node folder. Please provide me the information.


I have set the Background image like this

m.background ="background")
m.background.uri = "pkg:/images/Envoi.jpg"
0 Kudos
Channel Surfer

Re: Is there a way to execute a function every few secs


API call triggered in the timer but not going to the next actions.

When I set the timer to = true then only the next actions are working.

I need to call the api in timer for every 5 sec.

Based on the API response I have to stop the timer and navigating to another screen.

Xml file:

<?xml version="1.0" encoding="UTF-8"?>

<component name="PollUrlTask" extends="Task">

    <field id="url" type="string" />
    <field id="intervalSecs" type="integer" value="5" />

    <field id="deactivate" type="boolean" />
    <!-- watch this -->
    <field id="result" type="string" />

  <script type="text/brightscript" uri="PollUrlTask.brs" />



PollUrlTask.brs :

function fetch1(url as string) as string
req = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
if (left(url, 5) = "https") then req.SetCertificatesFile("common:/certs/ca-bundle.crt")
result = req.AsyncGetToString()
if result then
while true
msg = wait(0, port)
json = ParseJson(msg)
print "json.result.devicestatus" json.statusCode
if json.statusCode = 200 = json.result.token
print "userToken11111111"
if <> invalid = true
end if
else if json.statusCode = 401
end if
if type(msg) = "roUrlEvent" then
code = msg.GetResponseCode()
if code = 200 then
return msg.GetString()
return ""
end if
return ""
end if
end while
end if
return ""
end function

0 Kudos