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: 
Uzair_Abdullah
Streaming Star

Show Label in screen saver

I am trying to create a pretty simple screen saver; one with only a label that displays the current time.
So far I am only getting a blank screen. My label isn't even showing up.
Here's my code: 

ScreensaverFade.brs

function init()
   m.Label = m.top.findNode("time")
   m.global.observeField("MyField", "getCurrentTime")
end function

function getCurrentTime()
    time = CreateObject("roDateTime")
    time.getHours()
    time.toLocalTime()
    newTime = time.toISOString()
    print newTime
    arr = newTime.split("T")
    print "Time is: " arr[1]
    m.Label.text = arr[1]
end function

 

Main.brs:

sub RunScreenSaver()
   screen = createObject("roSGScreen")
    port = createObject("roMessagePort")
    port2 =  createObject("roMessagePort")
    screen.setMessagePort(port)

    m.global = screen.getGlobalNode() 'Creates (Global) variable MyField
    m.global.AddField("MyField", "int", true)
    m.global.MyField = 0
    scene = screen.createScene("ScreensaverFade")
    screen.show()

    while(true) 'Message Port that fires every 7 seconds to change value of MyField if the screen isn't closed
        msg = wait(7000, port)
        if (msg <> invalid)
            msgType = type(msg)
            if msgType = "roSGScreenEvent"
                if msg.isScreenClosed() then return
            end if
        else
            m.global.MyField += 10
            msg = wait(2500, port2)
        end if
    end while
end sub

Also, another minor issue, the time I am getting displays the date as well, so I used split to separate, now I get something like 09:30:22Z, what is his Z and how to remove it, and how to get my label to show up.
Thanks a lot!
Cheers!

 

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.