简体   繁体   中英

Roku Scenegraph SGDEX- Replace HDPosterURL variable

I am using a customer view, and I need to add a photo from the grid feed instead of the thumbnail. I cannot figure ut how to do this without changing the thumbnail. Is there a way to keep the thumbnail intact, and add a sperate photo for the CustomView? Below is the code. Would like to replace thumbnail with another image. Again, my app is a basic Roku SGDEX (scenegraph developer extensions) Custom + Screen

'''

'''parse from GridHandler
''' DetialsPosterUrl would be my custom image to replace the the thumbnail in the CustomView
function ParseMediaItemToNode(mediaItem as Object, mediaType as String) as Object
    itemNode = Utils_AAToContentNode({
        "id": mediaItem.id
        "title": mediaItem.title
        "hdPosterUrl": mediaItem.thumbnail
        "detailsPosterURL": mediaItem.detailsPoster
        "Description": mediaItem.shortDescription
        "Categories": mediaItem.genres[0]
    })


''' CustomView
sub ShowCustomView(hdPosterUrl as String)
    m.customView = CreateObject("roSGNode", "custom")
    m.customView.picPath = hdPosterUrl
    m.top.ComponentController.CallFunc("show", {
    view: m.customView
    })
end sub

'''deails view
sub OnDetailsContentSet(event as Object)
details = event.GetRoSGNode()
currentItem = event.GetData()
if currentItem <> invalid
    buttonsToCreate = []

    if currentItem.url <> invalid and currentItem.url <> ""
        buttonsToCreate.Push({ title: "Play", id: "play" })
    else if details.content.TITLE = "series" 
        buttonsToCreate.Push({ title: "Episodes", id: "episodes" })
    else if details.content.TITLE = "SERIES"
        buttonsToCreate.Push({ title: "Episodes", id: "episodes" })
    end if

    buttonsToCreate.Push({ title: "Details", id: "thumbnail" })   
'''
''' (more code irrevelant to topic)
'''
    else if selectedButton.id = "thumbnail"
    if details.currentItem.hdPosterUrl <> invalid then
        ShowCustomView(details.currentItem.hdPosterUrl)
    end if

''' 

custom.xml

 ''''
 <?xml version="1.0" encoding="utf-8" ?>
  <component name="custom" extends="Group" >
    <interface>
      <field id="picPath" type="string" alias="thumbnail.uri" />
    </interface>
    <children>
     <Poster id="thumbnail" translation="[0,0]" width="1280" height="720" />
    </children>
 </component>
 ''''

As your statement is conflicting(ie not clear whether you want to change the thumbnail or want to add a new node to display image), don't know what will be your preference. But both are possible. First you need to traceback to your custom component. After that, if you want to change thumbnail to show your required image, modify that node according to your need. If you want to add new node just add it everywhere where ever thumbnail node is added. Hope this will help.

In Your "ShowCustomView" function I see You are setting the "picPath" to be "hdPosterUrl", right? But what does that mean? Please check do You have "picPath" field set up inside "custom".xml file? Check does it have "alwaysNotify" set to true. Is "picPath" used inside ComponentController "show" function to set up url of some poster for the "custom" component? Check how do You pass data from ComponentController to the custom view. Hope it will help.

EDIT: Can You add different field itemNode to like this:

Utils_AAToContentNode({
        "id": mediaItem.id
        "title": mediaItem.title
        "hdPosterUrl": mediaItem.thumbnail
        "detailsPosterURL": mediaItem.detailsPoster
        "Description": mediaItem.shortDescription
        "Categories": mediaItem.genres[0]
        "ShortDescriptionLine1" : yourImageUrl
    })

Then use the "ShortDescriptionLine1" instead of hdPosterUrl . I have used ShortDescriptionLine1 since I assume that You are converting this to a regular, non custom content node. In that case You can use fields from this: Content Metadata or You can add custom fields with Update() function and not use fields from Content Metadata.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM