rokudev / SceneGraphDeveloperExtensions

Other
114 stars 65 forks source link

How to remove view from stack? #95

Closed RomanSkrypnyk-main closed 2 years ago

RomanSkrypnyk-main commented 2 years ago

How to remove Media View from stack? for deep linking

sub Input(args as object)
    ' handle roInput event deep linking
    ? "******REMOVE MEDIA VIEW FROM STACK!!!"
    if IsDeepLinking(args)
        PerformDeepLinking(args)
    end if
end sub

When media is played and a new curl link is installed, I want to remove the old view and set the new view (new video).

DeepLinking.brs

sub PerformDeepLinking(args as Object)
    ? "***Implement your deep linking logic.***"
    if (args.mediaType = "movie" or args.mediaType = "episode" or args.mediaType = "short-form" or args.mediaType = "series" or args.mediaType = "special")
        videoContent = createObject("RoSGNode", "ContentNode")
        videoContent.url = "http://hls.ted.com/talks/" + args.contentId + ".m3u8?stereoaudio=true"
        OpenVideoPlayerItem(videoContent)
    else
        ? "***Pop an error message and launch channel home page***"
        ShowErrorDialog("Something wrong with query.") 
    end if
end sub
RokuChris commented 2 years ago

To close a view and pop it off the stack, you set its close field... myView.close = true

There is a deep linking example in the Roku Recommends sample channel. https://github.com/rokudev/SceneGraphDeveloperExtensions/tree/master/samples/Roku_Recommends

RomanSkrypnyk-main commented 2 years ago

Thanks for pushing me in the right direction.

Solutions to my problem:

sub GetCurrentView()
    currentView = m.top.ComponentController.currentView
    if currentView.Subtype() = "MediaView" then currentView.close = true
end sub