2017-04-10 80 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的內容,並在頻道啓動後播放它。

相關問題