Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
ingsaurabh
Level 7

ObserveField problem with ECP

Hi, I am pushing a scene when ecp is received 

while(true)
        msg = wait(0, m.port)
        msgType = type(msg)
        if msgType = "roInputEvent"
            info = msg.GetInfo ()
           mediaMime = info.mediaMime
           if mediaMime.Instr("image") > -1 then
               displayImage(info)
            end if
        end if
    
        if msgType = "roSGScreenEvent"
            if msg.isScreenClosed() then return
        end if
    end while


and displayImage as, here onImageLoadStatusChange is never called.
function displayImage(args As Dynamic)
  screen = CreateObject("roSGScreen")
  m.port = CreateObject("roMessagePort")
  inputObject = CreateObject ("roInput")
  screen.setMessagePort(m.port)
  inputObject.SetMessagePort (m.port)
  scene = screen.CreateScene("ShowImage")
  screen.show()
  
  imageUrl = args.mediaPath
  
  m.image = scene.findNode("image")
  m.image.observeField("loadStatus", "onImageLoadStatusChange")
  m.image.uri = imageUrl
  
  while(true)
  print "req2"
    msg = wait(0, m.port)
    msgType = type(msg)
        if msgType = "roInputEvent"
            print "req2"
            info = msg.GetInfo ()
            handleInput(info)
        end if
    if msgType = "roSGScreenEvent"
      if msg.isScreenClosed() then return 0
    end if
  end while

end function

sub onImageLoadStatusChange()
  print "LoadingIndicator.brs - [onImageLoadStatusChange]"
  print m.image.loadStatus
  if m.image.loadStatus = "ready"
  print "ready"
  end if
end sub


What I think is, since I am pushing a node from Event loop hence the problem, correct me if I am wrong
So my question is how to push node in case of ECP? if my assumption is correct as stated above.
Why is obeserveField is not working?
0 Kudos
2 Replies
ingsaurabh
Level 7

Re: ObserveField problem with ECP

Any help here, does anybody face such issue?
0 Kudos
twig
Level 7

Re: ObserveField problem with ECP

Try this

sub onImageLoadStatusChange(evt as Object)
 status = evt.getData()
 print status
end sub
0 Kudos