2017-04-10 101 views
2

我需要帮助理解深度链接,因为我们的Roku场景图应用程序已被Roku拒绝。如何在Roku SG应用程序中实现深层链接?

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 

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

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

使用这个curl命令,应用程序启动成功显示了内容识别和mediaType的:

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

请帮助我们,并提供一个更好的例子来理解和容易实现深度链接。

回答

4

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

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

  1. 使用Eclipse插件 - >文件>导出> BrightScript部署。在DeepLinking PARAMS领域填补像这样:内容识别= 1234 &的MediaType =插曲

  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 

我希望这是在得到您的深层链接和运行很有帮助。让我知道如果我错过了什么。

1

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

相关问题