content: sub Main(args as Object)
      ShowChannelRSGScreen(args)
  end sub
  
  sub ShowChannelRSGScreen(args as Object)
      ' The roSGScreen object is a SceneGraph canvas that displays the contents of a Scene node instance
      screen = CreateObject("roSGScreen")
      ' ------  Deep Link ---------
      m.global = screen.getGlobalNode()
      ? "args= "; formatjson(args)      'pretty print AA'
      deeplink = getDeepLinks(args)
      ? "deeplink= "; deeplink
      m.global.addField("deeplink", "assocarray", false)
      m.global.deeplink = deeplink
      ' ------  Deep Link ---------
      ' message port is the place where events are sent
      m.port = CreateObject("roMessagePort")
      ' sets the message port which will be used for events from the screen
      screen.SetMessagePort(m.port)
      ' every screen object must have a Scene node, or a node that derives from the Scene node
      scene = screen.CreateScene("MainScene")
      screen.Show() ' Init method in MainScene.brs is invoked
      scene.observeField("exitApp", m.port)
      inputObject = createObject("roInput")
      inputObject.setMessagePort(m.port)
  
      ' event loop
      while(true)
          ' waiting for events from screen
          msg = wait(0, m.port)
          msgType = type(msg)
          if msgType = "roSGScreenEvent"
              if msg.IsScreenClosed() then return
          end if
          if msgType = "roInputEvent"
              if msg.IsInput()
                  info = msg.GetInfo()
                  if info.DoesExist("mediatype") and info.DoesExist("contentid")
                      mediaType = info.mediatype
                      contentId = info.contentid
                  end if
              end if
          else if msgType = "roSGNodeEvent" then
              field = msg.getField()
              if field = "exitApp" then
                  return
              end if
          end if
      end while
  end sub
  
  Function getDeepLinks(args) as Object
      deeplink = Invalid
  
      if args.contentid <> Invalid and args.mediaType <> Invalid
          deeplink = {
              id: args.contentId
              type: args.mediaType
          }
      end if
  
      return deeplink
  end Function