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

HDMI-CEC Implimentation

I'd like to impliment an action when a CECStatus event is triggered per: https://developer.roku.com/docs/references/brightscript/events/rocecstatusevent.md

To watch for this event, a message port needs to be opened. How would I you do this? 

Here's my main.brs:   Would I put it in here?


    screen   = CreateObject("roSGScreen")
    port     = CreateObject("roMessagePort")
    
    scene    = screen.CreateScene("MainScene")
    screen.setMessagePort(port)    
    screen.show()

    while(true)
        msg     = wait(0, port)
        msgType = type(msg)

        if msgType = "roSGScreenEvent"
            if msg.isScreenClosed() then return
        end if
    end while


Thanks
0 Kudos
1 REPLY 1
taylorcw
Streaming Star

Re: HDMI-CEC Implimentation

Figured out the issue. Documentation is incorrect. It should be:
CECStatus.IsActiveSource() to get the current CEC Status, not "ifCECStatus.IsActiveSource()"

    screen   = CreateObject("roSGScreen")
    port     = CreateObject("roMessagePort")
   cecstatus = CreateObject("roCECStatus")
    
  scene    = screen.CreateScene("MainScene")
    screen.setMessagePort(port) 
cecstatus.SetMessagePort(port)
  screen.show()

    while(true)
        msg     = wait(0, port)
        msgType = type(msg)

        if msgType = "roCECStatusEvent"
            print "RECEIVED roCECStatusEvent event"
            print "MSG STATUS: "; CECStatus.IsActiveSource()
        end if

        if msgType = "roSGScreenEvent"
            if msg.isScreenClosed() then return
        end if
    end while
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.