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

task node data loading from a json file

how can i load data from a json file through a task node instead of loading it in mainscene brs?

0 Kudos
3 REPLIES 3
TwitchBronBron
Streaming Star

Re: task node data loading from a json file

Take a look at this code from the Roku community sample projects. It does exactly what you're asking. 

 

https://github.com/rokucommunity/sample-projects/blob/669d4c2855d7bed3dc7eb4c62ec84c134f5c6462/stand...

0 Kudos
youssefsherif
Streaming Star

Re: task node data loading from a json file

this is when im using a rowlist right?

0 Kudos
youssefsherif
Streaming Star

Re: task node data loading from a json file

sub createRowItems(json as Object, listContent as Object)
  for each postDataContainer in json.data.children
    postData = postDataContainer.data
    post = {
      title: postData.title,
      selfText: postData.selfText,
      thumbnail: postData.thumbnail,
      isVideo: postData.is_video,
      url: postData.url,
      isSelf: postData.isSelf
    }

    if post.isVideo then
      itemContent = listContent.createChild("ContentNode")
      itemContent.update({ isSelf: post.isSelf }, true)
      itemContent.title = post.title
      itemContent.description = post.selfText
      itemContent.url = post.url

      if post.thumbnail <> "self" and post.thumbnail <> "default" and post.thumbnail <> "image" then
        itemContent.SDPosterUrl = post.thumbnail
      end if

      if post.isVideo then
        itemContent.url = post.url + "/DASHPlaylist.mpd"
        itemContent.streamformat = "dash"
      end if

      if postData.media <> invalid and postData.media.type = "youtube.com" then
        itemContent.videoUrl = postData.url
        itemContent.streamFormat = "youtube"
      end if

      extension = right(postData.url, 4)
      if extension = ".png" or extension = ".jpg" then
        itemContent.SDPosterUrl = postData.url
      end if

      itemContent.update({
        isRedditVideo: (postData.media <> invalid and postData.media.reddit_video <> invalid)
      }, true)
    end if
  end for
end sub

i believe ill be using this part

0 Kudos