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

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

Hello,

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 = m.top.findNode("background")
m.background.uri = "pkg:/images/Envoi.jpg"
 
 
0 Kudos
KiranPrasanna
Channel Surfer

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

Hello,

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

When I set the timer to m.top.deactivate = 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">

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

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

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

</component>

 

PollUrlTask.brs :

function fetch1(url as string) as string
req = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
req.SetMessagePort(port)
req.setRequest("POST")
req.SetUrl(url)
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
m.global.userToken = json.result.token
print "userToken11111111" m.global.userToken
if m.global.userToken <> invalid
m.top.deactivate = true
end if
else if json.statusCode = 401
activation()
end if
if type(msg) = "roUrlEvent" then
code = msg.GetResponseCode()
if code = 200 then
return msg.GetString()
else
return ""
end if
else
result.AsyncCancel()
return ""
end if
end while
end if
return ""
end function

0 Kudos