Forum Discussion

Blackhawk's avatar
Blackhawk
Roku Guru
6 years ago

springboard error

 

 

 

Im working on getting my channel to run with ads

 

' ********** Copyright 2016 Roku Corp.  All Rights Reserved. **********

' 1st function that runs for the scene component on channel startup
sub init()
  'To see print statements/debug info, telnet on port 8089
  m.Image         = m.top.findNode("Image")
  m.Details       = m.top.findNode("Details")
  m.Title         = m.top.findNode("Title")
  m.Video         = m.top.findNode("Video")
  m.SpringDetails = m.top.findNode("SpringBoardDetails")
  m.LabelList     = m.top.findNode("LabelList")
  m.CategoryLabel = m.top.findNode("CategoryLabel")
  m.RuntimeLabel  = m.top.findNode("RuntimeLabel")
  m.Video.ObserveField("state","OnVideoPlayerStateChange")
  m.Title.font.size = 40
  m.CategoryLabel.color = "#333333"
  m.Title.color = "#333333"
  m.Details.color = "#444444"
  m.RuntimeLabel.color = "#333333"
end sub

' set proper focus to buttons if Details opened and stops Video if Details closed
Sub onVisibleChange()
    ? "[DetailsScreen] onVisibleChange"
    if m.top.visible = true then
        m.buttons.jumpToItem = 0
        m.buttons.setFocus(true)
    else if m.videoPlayer <> invalid
        m.videoPlayer.visible = false
        m.videoPlayer.control = "stop"
        m.poster.uri=""
        m.background.uri=""
    end if
End Sub

' set proper focus to Buttons in case if return from Video PLayer
Sub OnFocusedChildChange()
    if m.top.isInFocusChain() and not m.buttons.hasFocus() and not m.videoPlayer.hasFocus() then
        m.buttons.setFocus(true)
    end if
End Sub

' set proper focus on buttons and stops video if return from Playback to details
Sub onVideoVisibleChange()
    if m.videoPlayer.visible = false and m.top.visible = true
        m.buttons.setFocus(true)
        m.videoPlayer.control = "stop"
        'clear video player content, for proper start of next video player 
        m.videoPlayer.content = invalid
        'remove video player
        m.top.removeChild(m.videoPlayer)
    end if
End Sub

' event handler of Video player msg
Sub OnVideoPlayerStateChange()
    if m.videoPlayer.state = "error"
        ' error handling
        m.videoPlayer.visible = false
    else if m.videoPlayer.state = "playing"
        ' playback handling
        playContent()
    else if m.videoPlayer.state = "finished"
        m.videoPlayer.visible = false
    end if
End Sub



sub playContent()
    content = m.buttons.content
    if content <> invalid then
        m.video.content = content
        m.video.visible = false

        m.PlayerTask = CreateObject("roSGNode", "PlayerTask")
        m.PlayerTask.observeField("state", "taskStateChanged")
        m.PlayerTask.video = m.video
        m.PlayerTask.control = "RUN"
    end if
end sub

sub taskStateChanged(event as Object)
    print "Player: taskStateChanged(), id = "; event.getNode(); ", "; event.getField(); " = "; event.getData()
    state = event.GetData()
    if state = "done" or state = "stop"
        exitPlayer()
    end if
end sub


' on Button press handler
Sub onItemSelected()
    ' first button is Play
    if m.top.itemSelected = 0
        m.videoPlayer = CreateObject("roSGNode", "Video")
        m.videoPlayer.id="videoPlayer"
        m.videoPlayer.translation="[0, 0]"
        m.videoPlayer.width="1280"
        m.videoPlayer.height="720"
        m.videoPlayer.content   = m.top.content

        'show video player
        m.top.AppendChild(m.videoPlayer)

        m.videoPlayer.visible = true
        m.videoPlayer.setFocus(true)
        m.videoPlayer.control = "play"
        m.videoPlayer.observeField("state", "OnVideoPlayerStateChange")
        m.videoPlayer.observeField("visible", "onVideoVisibleChange")

    end if
End Sub

' Content change handler
Sub OnContentChange()
    m.description.content   = m.top.content
    m.description.Description.width = "770"
    m.poster.uri            = m.top.content.hdBackgroundImageUrl
    m.background.uri            = m.top.content.hdBackgroundImageUrl
End Sub

'///////////////////////////////////////////'
' Helper function convert AA to Node
Function ContentList2SimpleNode(contentList as Object, nodeType = "ContentNode" as String) as Object
    result = createObject("roSGNode",nodeType)
    if result <> invalid
        for each itemAA in contentList
            item = createObject("roSGNode", nodeType)
            item.setFields(itemAA)
            result.appendChild(item)
        end for
    end if
    return result
End Function

Function OnkeyEvent(key, press) as Boolean
    ? ">>> Details >> OnkeyEvent"
    result = false
    if press AND key = "back" AND m.videoPlayer <> invalid AND m.videoPlayer.visible 
        m.videoPlayer.visible = false
        result = true    
    end if
    return result
End Function

 

Yet I keep getting these errors

Invalid value for left-side of expression. (runtime error &he4) in pkg:/components/SpringBoard.brs(117)                 117:     m.description.content   = m.top.content 

 

6 Replies

  • It looks like you have overlooked defining `

    m.description

     

    • joetesta's avatar
      joetesta
      Roku Guru

      probably in the init() you need to add 
      m.description = m.top.findNode("description")

  •  

    I managed to get around it

    ' ********** Copyright 2016 Roku Corp.  All Rights Reserved. **********
    
    ' 1st function that runs for the scene component on channel startup
    sub init()
      'To see print statements/debug info, telnet on port 8089
      m.Image         = m.top.findNode("Image")
      m.Details       = m.top.findNode("Details")
      m.Title         = m.top.findNode("Title")
      m.Video         = m.top.findNode("Video")
      m.SpringDetails = m.top.findNode("SpringBoardDetails")
      m.LabelList     = m.top.findNode("LabelList")
      m.CategoryLabel = m.top.findNode("CategoryLabel")
      m.RuntimeLabel  = m.top.findNode("RuntimeLabel")
      m.Video.ObserveField("state","OnVideoPlayerStateChange")
      m.Title.font.size = 40
      m.CategoryLabel.color = "#333333"
      m.Title.color = "#333333"
      m.Details.color = "#444444"
      m.RuntimeLabel.color = "#333333"
    end sub
    
    Sub OnVideoPlayerStateChange()
      print "SpringBoard.brs - [OnVideoPlayerStateChange]"
      if m.Video.state = "error"
        ' error handling
        m.Video.visible = false
      else if m.Video.state = "playing"
        ' playback handling
      else if m.Video.state = "finished"
        m.video.visible = false
        m.SpringDetails.Visible=true
        m.LabelList.setFocus(true)
      end if
    End Sub
    
    sub onContentChange(event as object)
      print "onContentChange"
      content = event.getdata()
    
      runtime = content.shortdescriptionline2.toInt()
      minutes = runtime \ 60
      seconds = runtime MOD 60
    
      m.Image.uri = content.hdposterurl
      m.Title.text = content.title
      m.Details.text = content.description
      x = m.Details.localBoundingRect()
      m.RuntimeLabel.text = "Length: " + minutes.toStr() + " minutes " + seconds.toStr() + " seconds"
      translation = [m.RuntimeLabel.translation[0], m.Details.translation[1] + x.height + 30]
      m.RuntimeLabel.translation = translation
      m.CategoryLabel.text = content.categories
    
      ContentNode = CreateObject("roSGNode", "ContentNode")
      ContentNode.streamFormat = content.streamformat
      ContentNode.url = content.url
      ContentNode.Title = content.title
      ContentNode.Description = content.Description
      ContentNode.ShortDescriptionLine1 = content.title
      ContentNode.StarRating = 80
      ContentNode.Length = 1972
      ContentNode.subtitleConfig = {Trackname: "pkg:/source/CraigVenter.srt" }
    
      m.Video.content = ContentNode
    end sub
    
    
    
    sub onItemSelected(event as object)
      print "onItemSelected"
      m.Video.control = "play"
      if event.getData() <> 0 then m.Video.seek = m.top.seekposition
      m.SpringDetails.visible = false
      m.Video.visible = true
      m.Video.setFocus(true)
    end sub
    
    ' Called when a key on the remote is pressed
    function onKeyEvent(key as String, press as Boolean) as Boolean
      print "in SimpleVideoScene.xml onKeyEvent ";key;" "; press
      if press then
        if key = "back"
          print "------ [back pressed] ------"
          if m.Video.visible
            m.Video.control = "pause"
            m.Video.visible = false
            m.SpringDetails.visible = true
            position = m.Video.position
            if position > 0
              if m.LabelList.content.getChildCount() > 1 then m.LabelList.content.removeChildIndex(1)
              minutes = position \ 60
              seconds = position MOD 60
              contentNode = createObject("roSGNode","ContentNode")
              contentNode.title = "Resume Video (" + minutes.toStr() + " min " + seconds.toStr() + " sec)"
              m.LabelList.content.appendChild(contentNode)
              'Write position to registry so that re-opening the channel works
              m.global.registryTask.write = {
                contentid: m.top.content.episodenumber,
                position: position.toStr()
              }
              m.top.seekposition = position
            else
              print "Do nothing"
            end if
            m.LabelList.setFocus(true)
            return true
          else
            return false
          end if
        else if key = "OK"
          print "------- [ok pressed] -------"
        else
          return false
        end if
      end if
      return false
    end function

    It wont show the ad as it was stuck on the retrieving screen so I checked what's wrong with it and this error popped up

    Interface not a member of BrightScript Component (runtime error &hf3) in pkg:/components/SpringBoard.brs(46)   

     

     

     

    • joetesta's avatar
      joetesta
      Roku Guru

      Assuming that line 46 is 

      m.Details.text = content.description

      Then I'm going to suggest you pay attention to my earlier reply. good luck.

      • Blackhawk's avatar
        Blackhawk
        Roku Guru

         

        I added it on this code

         

         

         

         

        ' ********** Copyright 2016 Roku Corp.  All Rights Reserved. ********** 
         ' inits details screen
         ' sets all observers 
         ' configures buttons for Details screen
        Function Init()
            ? "[DetailsScreen] init"
        
            m.top.observeField("visible", "onVisibleChange")
            m.top.observeField("focusedChild", "OnFocusedChildChange")
        
            m.buttons           =   m.top.findNode("Buttons")
            m.Player            =   m.top.findNode("VideoPlayer")
            m.poster            =   m.top.findNode("Poster")
            m.description       =   m.top.findNode("Description")
            m.background        =   m.top.findNode("Background")
        
        
            ' create buttons
            result = []
            for each button in ["Play"]
                result.push({title : button})
            end for
            m.buttons.content = ContentList2SimpleNode(result)
        End Function
        
        ' set proper focus to buttons if Details opened and stops Video if Details closed
        Sub onVisibleChange()
            ? "[DetailsScreen] onVisibleChange"
            if m.top.visible = true then
                m.buttons.jumpToItem = 0
                m.buttons.setFocus(true)
            else
                m.Player.visible = false
                m.Player.control = "stop"
                m.poster.uri=""
                m.background.uri=""
            end if
        End Sub
        
        ' set proper focus to Buttons in case if return from Video PLayer
        Sub OnFocusedChildChange()
            if m.top.isInFocusChain() and not m.buttons.hasFocus() and not m.Player.hasFocus() then
                m.buttons.setFocus(true)
            end if
        End Sub
        
        ' set proper focus on buttons and stops video if return from Playback to details
        Sub onVideoVisibleChange()
            if m.Player.visible = false and m.top.visible = true
                m.buttons.setFocus(true)
                m.Player.control = "stop"
            end if
        End Sub
        
        ' event handler of Video player msg
        Sub OnVideoPlayerStateChange()
            if m.Player.state = "error"
                ' error handling
                m.Player.visible = false
            else if m.Player.state = "playing"
        	playContent()
                ' playback handling
            else if m.Player.state = "finished"
                m.Player.visible = false
            end if
        End Sub
        
        sub playContent()
            content = m.buttons.content
            if content <> invalid then
                m.video.content = content
                m.video.visible = false
        
                m.PlayerTask = CreateObject("roSGNode", "PlayerTask")
                m.PlayerTask.observeField("state", "taskStateChanged")
                m.PlayerTask.video = m.video
                m.PlayerTask.control = "RUN"
            end if
        end sub
        
        ' on Button press handler
        Sub onItemSelected()
            ' first button is Play
             if m.top.itemSelected = 0
                m.Player = CreateObject("roSGNode", "Video")
                m.Player.id="videoPlayer"
                m.Player.translation="[0, 0]"
                m.Player.width="1280"
                m.Player.height="720"
                m.Player.content   = m.top.content
        
                'show video player
                m.top.AppendChild(m.videoPlayer)
        
                m.Player.visible = true
                m.Player.setFocus(true)
                m.Player.control = "play"
                m.Player.observeField("state", "OnVideoPlayerStateChange")
                m.Player.observeField("visible", "onVideoVisibleChange")
        
            end if
        End Sub
        
        ' Content change handler
        Sub OnContentChange()
            m.description.content   = m.top.content
            m.description.Description.width = "770"
            m.Player.content   = m.top.content
            m.top.streamUrl         = m.top.content.url
            m.poster.uri            = m.top.content.hdBackgroundImageUrl
            m.background.uri            = m.top.content.hdBackgroundImageUrl
        End Sub
        
        '///////////////////////////////////////////'
        ' Helper function convert AA to Node
        Function ContentList2SimpleNode(contentList as Object, nodeType = "ContentNode" as String) as Object
            result = createObject("roSGNode",nodeType)
            if result <> invalid
                for each itemAA in contentList
                    item = createObject("roSGNode", nodeType)
                    item.setFields(itemAA)
                    result.appendChild(item)
                end for
            end if
            return result
        End Function

         

         

         

         

         

        I keep geting this error

         

        Current Function: 070: sub playContent() 071: content = m.buttons.content 072: if content <> invalid then 073:* m.video.content = content 074: m.video.visible = false 075: 076: m.PlayerTask = CreateObject("roSGNode", "PlayerTask") 077: m.PlayerTask.observeField("state", "taskStateChanged") Invalid value for left-side of expression. (runtime error &he4) in pkg:/components/screens/DetailsScreen/DetailsScreen.brs(73) 073: m.video.content = content