rokudev / SceneGraphDeveloperExtensions

Other
114 stars 64 forks source link

How to get content from Grid Screen for Deep Linking? #94

Closed RomanSkrypnyk-main closed 1 year ago

RomanSkrypnyk-main commented 2 years ago

I try to get content from Grid Screen for Deep Linking. ? m.grid.content returned:

SGDEX: create new view: GridView
<Component: roSGNode:ContentNode> =
{
    change: <Component: roAssociativeArray>
    focusable: false
    focusedChild: <Component: roInvalid>
    id: ""
    handlerconfiggrid: <Component: roAssociativeArray>
}

My MainSceene.brs

sub Show(args as Object)
    ShowHomeScreen()
    if IsDeepLinking(args)
        PerformDeepLinking(args)
    end if
    m.top.signalBeacon("AppLaunchComplete")
end sub
sub Input(args as object)
    ' handle roInput event deep linking
    if IsDeepLinking(args)
        PerformDeepLinking(args)
    end if
end sub

function ShowHomeScreen() as Object
    m.grid = CreateObject("roSGNode", "GridView")
    m.grid.theme = {
        backgroundColor: "#07575B"
        focusRingColor: "#C4DFE6"
    }
    m.grid.SetFields({
        style: "hero"
        posterShape: "4x3"
    })
    content = CreateObject("roSGNode", "ContentNode")
    content.AddFields({
        HandlerConfigGrid: {
            name: "HomeCH"
        }
    })
    m.grid.content = content
    ? m.grid.content
    m.grid.ObserveField("rowItemSelected", "OnGridItemSelected")
    m.top.ComponentController.CallFunc("show", {
        view: m.grid
    })
    return m.grid
end function

I am expect:

<Component: roSGNode:ContentNode> =
{
    change: <Component: roAssociativeArray>
    focusable: false
    focusedChild: <Component: roInvalid>
    id: "83223"
    ACTORS: <Component: roArray>
    CATEGORIES: <Component: roArray>
    DESCRIPTION: "A net-zero future is possible, but first we need to flip a mental switch to truly understand that we can stop the climate crisis if we try, says Nobel laureate Al Gore. In this inspiring and essential talk, Gore shares examples of extreme climate events (think: fires, floods and atmospheric tsunamis), identifies the man-made systems holding us back from progress and invites us all to join the movement for climate justice: "the biggest emergent social movement in all of history," as he puts it.  An unmissable tour de force on the current state of the crisis --  and the transformations that will make it possible to find a way out of it."
    HDPOSTERURL: "https://pe.tedcdn.com/images/ted/4ddec59e255580a6273d2a195eb4c4ca8b1aa705_615x461.jpg"
    LENGTH: 0
    RATING: ""
    RELEASEDATE: "2021-11-02 18:04:34"
    SHORTDESCRIPTIONLINE1: ""
    SHORTDESCRIPTIONLINE2: ""
    STARRATING: 0
    TITLE: "Al Gore: How to make radical climate action the new normal"
    URL: "http://hls.ted.com/talks/83223.m3u8?stereoaudio=true"
}

(the next code is from details screen after pressed button and item for details is loaded)

So the main problem is to get the content whose Content Node is to be set to the DeepLink method and make a FindNodeById request. playableItem = FindNodeById(content, contentId) ' find deep link content by contentId

I will be grateful for the answer.

RokuChris commented 2 years ago

This is expected. You're printing m.grid.content before your ContentHandler runs. The ContentHandler runs when you show the view. You need to wait until the ContentHandler is done if you need to do something with its result. Several of the sample channels show how to do this by adding an isContentLoaded field to the ContentNode and then setting it from the ContentHandler when it is done.

https://github.com/rokudev/SceneGraphDeveloperExtensions/tree/master/samples/Roku_Recommends

RomanSkrypnyk-main commented 1 year ago

Thanks for pushing me to the right place. https://github.com/rokudev/SceneGraphDeveloperExtensions/tree/master/samples/Roku_Recommends