How to Implement Deep Linking in Roku Channel?
Deep Linking in Roku Channel is mainly used for launching the public channel, performing the universal search and for directly opening to a specific part of the video that is in a public channel.
Deep Linking launches a small piece of video part using parameters passed to the channel at launch time, rather than launching the main or home page of the channel.
According to the latest Roku app development certification list, we need to implement the deep link to pass the certification for all the public channels.
The basic steps to implement Deep Linking in Roku Channel in a channel are:
- Step 1: Modify the channel’s main.brs file.
- Step 2: Test that args[contentid] and args[MediaType] are valid.
- Step 3: Add code for launching.
- Step 4: For a series, implement bookmarking.
- Step 5: Use roInputEvent.
- Step 6: Test using the Deep Linking in Roku Channel Tester application
Step 1: Modify the channel’s main.brs file.
Modify your channel to implement Deep Linking in Roku Channel by updating your channel’s main() or runuserinterface().
Function Main (args as Dynamic) as Void
Parse the associative array passed in to your channel’s main(). Content item is a part of Deep Linking in Roku Channel parameters which is defined as an associative array of two keys, contentid and mediaType.
ContentId in Roku Channel
A contentid is a unique identifier associated with a single piece of content. A contentid are:
- an opaque string – The format of a contentid is defined by your channel, not Roku, and the contentid is opaque to the Roku system.
- a single string – The contentid must be no more than 255 characters long.
- a constant value to identify a specific part of content – The ID must identify the same content.
- URL encoded – The contentid must be URL encoded.
- a command-line argument – The contentid must be passable as a command-line argument in a cURL command.
MediaType in Roku Channel
A mediaType is a value used to differentiate between different types of content available on your Roku channel. Roku has defined the mediaType values as:
Step 2: Test that args[contentid] and args[MediaType] are valid.
Added an implementation to check args[contentid] and args[MediaType] are not invalid. If they are valid, the channel is being deep linked to. Otherwise, do a normal channel launch.
if (args.mediaType <> invalid) and (args.contentid <> invalid)
Step 3: Add code for launching.
Add implementation to launch the particular screen using the content id and media type accordingly, unless your contentid and mediaType are invalid. If they are invalid, it shows an error and launches the channel normally.
Step 4: For a series, implement bookmarking.
Decide which episode to play. Go to the particular part of the video and start playback.
Step 5: Use roInputEvent.
The roInput component enables Deep Linking in Roku Channel without re-launching your channel. When the firmware resolves a voice input request, your application can send the deep link parameters through the roInputEvent — instead of re-launching your channel with the parameters.
Step 6: Test using the Deep Linking Tester application
You can test your Deep Linking in Roku Channel using Deep Linking in Roku Channel tester app
Read more about How to Update an Existing Roku Application?
Please find a few Roku applications, that we developed in recent times here.