【问题标题】:How to implement Deep Linking in Roku SG application?如何在 Roku SG 应用程序中实现深度链接?
【发布时间】:2017-09-05 01:26:44
【问题描述】:

我需要帮助理解深度链接,因为我们的 Roku 场景图应用程序被 Roku 拒绝了。

Roku 在此处解释深度链接:https://sdkdocs.roku.com/display/sdkdoc/Deep+Linking,但该文档并未详细说明有关深度链接的所有信息。例如,我们如何获取 contentId 和 mediaType?

这是我们在启动时运行的main() 函数:

function main(args as Dynamic) as Void
    print "args" args
    if (args.ContentId <> invalid) and (args.MediaType <> invalid)
        if (args.mediaType = "season")
            HomeScreen()
        end if 
    end if
end function

应用程序启动后,我们打印 args,得到这个关联数组。但是,这不会显示任何 contentId 和 mediaType。

<Component: roAssociativeArray> =
{
    instant_on_run_mode: "foreground"
    lastExitOrTerminationReason: "EXIT_UNKNOWN"
    source: "auto-run-dev"
    splashTime: "1170"
}

使用此 curl 命令,应用程序成功启动并显示 contentId 和 mediaType:

curl -d "" "http://10.1.1.114:8060/launch/dev?contentID=e59066f501310da32b54ec0b64319be0&MediaType=season"

请帮助我们并提供更好的示例来轻松理解和实施深度链接。

【问题讨论】:

    标签: roku brightscript scenegraph


    【解决方案1】:

    你在正确的轨道上。深度链接的目的是让用户从 Roku 搜索列表或横幅直接访问您频道的季节或剧集。

    文档中没有一个很好的例子来说明如何为场景图通道编程,所以我们也必须自己编写。一旦你实现了它,有几种方法可以测试它:

    1. 使用 Eclipse 插件 -> 文件 > 导出 > BrightScript 部署。像这样填写 DeepLinking params 字段:contentID=1234&MediaType=episode

    2. 使用 Roku 深度链接测试器:http://devtools.web.roku.com/DeepLinkingTester/

    3. 将一些深层链接参数硬编码到您的频道中

    以下是我们在 main.brs 中实现深度链接逻辑的方式:

    sub Main(args as Dynamic)
    
        screen = createObject("roSGScreen")
        m.port = createObject("roMessagePort")
        screen.setMessagePort(m.port)
        m.global = screen.getGlobalNode()
    
        'Deep Linking
        'args.ContentId = "78891" 'Testing only
        'args.MediaType = "episode" 'Testing only
        if (args.ContentId <> invalid) and (args.MediaType <> invalid)
            m.global.addField("DeepContentId", "string", true)
            m.global.addField("DeepMediaType", "string", true)
    
            m.global.DeepContentId = args.ContentId
            m.global.DeepMediaType = args.MediaType
        end if
    
        scene = screen.createScene("HomeScene")
        screen.show()
    
        '...load content, other startup logic
    
        while true
            msg = wait(0, m.port)
            msgType = type(msg)
    
            if msgType = "roSGScreenEvent"
                if msg.isScreenClosed() then exit while
            end if
        end while
    
        if screen <> invalid then
            screen.close()
            screen = invalid
        end if
    end sub
    

    然后在 HomeScene.brs 中的主屏幕上,一旦您的内容初始化:

    'Check for deep link content
    if m.global.DeepContentId <> invalid then
    
        if (m.global.DeepMediaType = "short form" or m.global.DeepMediaType = "movie" or m.global.DeepMediaType = "episode") then
            'find selected content in feed
    
            'play episode or movie content directly
    
        else if (m.global.DeepMediaType = "season")
            'find selected content in feed
            'show season screen for content
        else
            ? "Unrecognized Deep Link Media Type"
        end if
        'It may be necessary to remove deep link params
        m.global.DeepContentId = invalid
        m.global.DeepMediaType = invalid
    end if
    

    我希望这有助于启动和运行您的深层链接。如果我错过了什么,请告诉我。

    【讨论】:

    【解决方案2】:

    深度链接参数由固件传递。如果它们通过,您应该只能处理它们。如果没有传递参数,只需显示主屏幕。例如,如果您在“args”中有有效的 contentId,您应该找到具有该 ID 的内容并在频道启动后播放。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-14
      • 2020-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多