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

roTimer SetPort

Hello Everyone,

New here to Roku development, I have been tasked with creating a Roku application that will allow users to stream our radio stations audio. So far everything has been moving along great.

One of the requirements is that we display the current artist, song and DJ information while streaming. We have an XML web service I have been able to consume to gather this information. However I have been unsuccessful in setting up some sort of timer to make this call at a certain interval.

So far I have the isolated code below in an attempt to setup some sort of timeout. But when attempting to set the port I receive the following error:

'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in ...w5E0T/pkg:/source/SandBox.brs(11)
011: timer.SetPort(msgPort)



sub Main()
SetTheme()

msgPort = CreateObject("roMessagePort")
sysTime = CreateObject("roSystemTime")
timer = CreateObject("roTimer")

timer.SetPort(msgPort)

timeout = sysTime.GetLocalDateTime()
timeout.AddSeconds(10)

timer.SetDateTime(timeout)
timer.Start()

while true
msg = wait(0, msgPort)
if type(msg) = "roTimerEvent " then
print "10 seconds has elapsed"

timeout=sysTime.GetLocalDateTime()
timeout.AddSeconds(10)

timer.SetDateTime(timeout)
timer.Start()

end if
end while

end sub


I have been scouring these boards and the SDK examples and I see this syntax used in many places. It is quite possible I am doing something incorrectly. From everything I have read, and used up until this point. It seems like a typical event loop, could anyone point out what may be wrong? Or point me to any resources you may think could be helpful? Thanks!

Regards,
Jonathan
0 Kudos
4 REPLIES 4
RokuChris
Roku Employee
Roku Employee

Re: roTimer SetPort

roSystemTime and roTimer are not valid components (http://sdkdocs.roku.com/display/RokuSDKv48/Components), so your calls to CreateObject() are returning invalid.

You probably want roDateTime (http://sdkdocs.roku.com/display/RokuSDKv48/roDateTime) and roTimespan (http://sdkdocs.roku.com/display/RokuSDKv48/roTimespan)
0 Kudos
jpalumbo
Visitor

Re: roTimer SetPort

Awesome, thanks for the speedy reply.
0 Kudos
RachitGaur
Visitor

Re: roTimer SetPort

How to create async function call in brightscript for ROKU TV ? just like in javascript setInterval()
0 Kudos
RokuMarkn
Visitor

Re: roTimer SetPort

See the "Timed Events" section in Event Loops in the documentation.

--Mark
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.