Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
xoceunder
Level 10

Help with Poster Grid does not show all the information

Jump to solution

Help with Poster Grid does not show all the information I am using this Screenshot_5.png

GetEpisodes.brs

sub init()
    m.top.functionName = "go"
end sub

sub go()
    content = createObject("roSGNode", "ContentNode")
	episode = jsonCapitulos(m.top.season)
	if episode <> invalid then
      for each item in episode
        seasons = content.createChild("ContentNode")
        seasons.id = item.id.toStr()
        seasons.ContentType = "4"
        seasons.title = item.title
		seasons.EpisodeNumber = item.episode_num.toStr()
		seasons.url = m.global.serverURL + m.global.play + item.id.toStr()+"."+item.container_extension
		seasons.shortdescriptionline1 = "S" + item.season.toStr() + "E" + item.episode_num.toStr()
		if item.info <> invalid and item.info.count() <> 0
         seasons.description = item.info.plot.toStr()
         seasons.releaseDate = item.info.releasedate
		 seasons.hdgridposterurl = item.info.movie_image
         seasons.HDBackgroundImageUrl = item.info.movie_image
         seasons.shortdescriptionline2 = item.info.plot.toStr()
		end if
      end for 
	end if
    m.top.content = content
End sub

sub jsonCapitulos(season As String) As Object
	url = m.global.serverURL + m.global.episode + m.top.cve
    data = requestData(url)
    json = ParseJSON(data)
    if json <> invalid and json.episodes <> invalid then
        return json.episodes[season]
    else
        return {}
    end if
End sub

 

Seasons.brs

sub Init()
  'print "[Seasons.brs] - init"
  
  m.top.observeField("visible", "onVisibleChange")
  
  m.loading           =   m.top.findNode("LoadingIndicator")
  m.buttons           =   m.top.findNode("Buttons")
  m.playbuttons       =   m.top.findNode("PlayButtons")
  m.videoPlayer       =   m.top.findNode("VideoPlayer")
  m.poster            =   m.top.findNode("Cover")
  m.description       =   m.top.findNode("lblDescription")
  m.background        =   m.top.findNode("Background")
  m.fadeIn            =   m.top.findNode("fadeinAnimation")
  m.fadeOut           =   m.top.findNode("fadeoutAnimation")
  m.tilte             =   m.top.findNode("lblTitle")
  m.date              =   m.top.findNode("lblDate")
  m.rating            =   m.top.findNode("lblRating")
  m.episodesgrid      =   m.top.findNode("EpisodesGrid")
  
  m.savePositionToReg = createObject("roSGNode", "WriteVideoPosition")
  m.savePositionToReg.section = "SerieResume"
  
  m.seasons = createObject("roSGNode", "GetSeasons")
  m.seasons.observeField("content", "createSeasons")
  
  m.episodes = createObject("roSGNode", "GetEpisodes")
  m.episodes.observeField("content", "setEpisodes")
  
  m.videoPlayer.observeField("state", "OnVideoPlayerStateChange")
  m.videoPlayer.observeField("position", "savePosition")
  m.episodesgrid.observeField("itemSelected", "onEpisodeSelected")
End sub

sub createSeasons()
    'print "[Seasons.brs] - createseasons"
    m.buttons.content = m.seasons.content
    m.buttons.visible = true
    m.loading.control = "stop"
end sub

sub setEpisodes()
    'print "[Seasons.brs] - setepisodes";
    if m.episodes.content.getChild(0) = invalid then
        m.buttons.visible = true
        m.buttons.setFocus(true)
        m.loading.control = "stop"
    else 
        print "SetEpisodes in grid";
        m.episodesgrid.content = m.episodes.content
        m.episodesgrid.visible = true
        m.episodesgrid.setFocus(true)
        m.loading.control = "stop"
    end if
end sub

' set proper focus to buttons if Details opened and stops Video if Details closed
Sub onVisibleChange()
  'print "Seasons.brs - [onVisibleChange]"
  if m.top.visible
    m.fadeIn.control="start"
    m.buttons.jumpToItem = 0
    m.buttons.visible = true
    m.buttons.setFocus(true)
    checkFavorite()
  else
    m.fadeOut.control="start"
    m.buttons.visible = false
    m.poster.uri=""
    m.background.uri=""
  end if
End Sub

' set proper focus on buttons and stops video if return from Playback to details
Sub onVideoVisibleChange()
  'print "Seasons.brs - [onVideoVisibleChange]"
  if m.videoPlayer.visible = false and m.top.visible = true
    m.episodesgrid.setFocus(true)
    m.episodesgrid.observeField("itemSelected", "onEpisodeSelected")
    m.videoPlayer.control = "stop"
  else 
    m.episodesgrid.unobserveField("itemSelected")
  end if
End Sub

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

Sub onEpisodeFocused()
    'print "Seasons.brs - [onEpisodeFocused]"
    m.videoPlayer.content  = m.episodesgrid.content.getChild(m.top.episodeFocused)
    m.videoPlayer.content.HttpHeaders = m.headers
    m.videoPlayer.control = "prebuffer"
End Sub

' on Button press handler
Sub onItemSelected()
  'print "Seasons.brs - [onItemSelected] "
  m.loading.control = "start"
  m.episodes.cve = m.top.content.id
  m.episodes.season = m.buttons.content.getChild(m.buttons.itemSelected).id
  m.episodes.control = "RUN"
  m.buttons.visible = false
End Sub

sub onEpisodeSelected()
    'print "Seasons.brs - [onEpisodeSelected]"
    m.resume = createObject("roSGNode", "ResumeVideo")
    m.resume.section = "SerieResume"
    m.resume.cve = m.videoPlayer.content.episodeNumber
    m.resume.control = "RUN"
    m.resume.observeField("state","resume")
end sub

sub resume()
    'print "Seasons.brs - [Resume] Seconds in reg: " ; m.resume.pos
    if m.resume.state = "stop"
        if m.resume.pos >= 60 then
            m.dialog = createObject("roSGNode", "Dialog")
            m.dialog.title = "Resume"
            m.dialog.optionsDialog = true
            minutes = int(m.resume.pos/60)
            seconds = int(m.resume.pos MOD 60)
            secondsStr = seconds.toStr()
            if seconds < 10 then secondsStr = "0" + seconds.toStr()
            resumePos = "Resume from " + minutes.tostr() + ":" + secondsStr
            m.dialog.buttons = [resumePos,"Start from beginning"]  
            m.top.getScene().dialog = m.dialog
            m.dialog.observeField("buttonSelected","resumeSelected")
        else
            playEpisode()
        end if
    end if
    'm.resume.unobserveField("pos")
end sub

sub resumeSelected()
    'print "Seasons.brs - [ResumeSelected]"
    if m.dialog.buttonSelected = 0 then
        m.videoPlayer.seek = m.resume.pos
        playEpisode()
    else
        playEpisode()
    end if
    m.dialog.close = true
end sub

sub playEpisode()
'print "[Seasons.brs] - playEpisode"
    'print "Play episode: "; m.videoPlayer.content
    m.videoPlayer.visible = true
    m.videoPlayer.setFocus(true)
    m.videoPlayer.control = "play"
end sub

sub savePosition()
    if int(m.videoPlayer.position) MOD 2 = 0 and m.videoPlayer.position > 10 then
        'print "Seasons.brs - [savePosition] Seconds:"; m.videoPlayer.position
        m.savePositionToReg.cve = m.videoPlayer.content.episodeNumber
        m.savePositionToReg.pos = m.videoPlayer.position - 10
        m.savePositionToReg.control = "RUN"
    end if 
end sub

' Content change handler
Sub OnContentChange()
  'print "Seasons.brs - [OnContentChange]"
  m.description.text           = m.top.content.description
  m.poster.uri                 = m.top.content.HDPosterUrl
  m.background.uri             = m.top.content.hdBackgroundImageUrl
  m.tilte.text                 = m.top.content.title
  m.date.text                  = m.top.content.releasedate
  m.rating.text                = m.top.content.rating
  
  if m.seasons.cve <> m.top.content.id then
      m.buttons.content = invalid
      m.loading.control = "start"
      m.seasons.cve = m.top.content.id
      m.seasons.control = "RUN" 
      m.buttons.visible = false
  end if
end Sub


' Called when a key on the remote is pressed
function onKeyEvent(key as String, press as Boolean) as Boolean
  'print ">>> Seasons >> OnkeyEvent"
  result = false
  'print "in Seasons.xml onKeyEvent. Key pressed: ";key;" - Press: "; press
  if press then
    if key = "back"
      'print "------ [back pressed] ------"
      'back from episodes to seasons
      if m.buttons.visible = false and m.videoplayer.visible = false and m.episodesgrid.visible = true
        m.episodesgrid.visible = false
        m.episodes.observeField("content", "setEpisodes")
        m.buttons.visible = true
        m.buttons.setFocus(true)
        result = true
      end if
    else if key = "up"
        if m.top.visible and m.buttons.visible
            m.buttons.jumpToItem = 0
        end if
    end if
  end if
  'print "Handled event: "; result
  return result
end function
0 Kudos
1 Solution

Accepted Solutions
xoceunder
Level 10

Re: Help with Poster Grid does not show all the information

Jump to solution
0 Kudos
3 Replies
xoceunder
Level 10

Re: Help with Poster Grid does not show all the information

Jump to solution

help this solution

0 Kudos
roAmanda
Roku Employee
Roku Employee

Re: Help with Poster Grid does not show all the information

Jump to solution

A recommended first step you may have already tried, is to look at the data for the grid info that is working and then compare it with the sections that are missing to see if there are errors in the data. We can take a closer look, as needed, you will need to provide Partner Success with the URL for the data feed so that we can look at it to see if there is an issue with the feed. Thank you!!

 

0 Kudos
xoceunder
Level 10

Re: Help with Poster Grid does not show all the information

Jump to solution
0 Kudos