DEV Community

Uros Mitic
Uros Mitic

Posted on • Updated on

How to launch a Roku channel from within another Roku channel

Launching one application from another on Roku platform sounds pretty cool right?
It also sounds complicated, especially if you are following Roku Documentation.
So I will try to explain it as simple as possible.
In this article I will focus only on part of the code that is responsible for launching another channel, if you want to check the whole project, go here:
https://github.com/umitic/Roku-Channel-Within

Let us start:

What you are actually doing, when You are launching Roku channel from within another channel is basically sending URL request to your Roku device.
Nothing fancy there, right?
To be able to do this we will use Roku External Control API.

Here is the code for launching another app from the Task:

deviceInfo = CreateObject("roDeviceInfo")
deviceIP = deviceInfo.GetIPAddrs().eth1

urlString = "http://" + deviceIP + ":8060/launch/12"     

request = CreateObject("roUrlTransfer")
request.SetUrl(urlString)
request.AsyncPostFromString(urlString)
Enter fullscreen mode Exit fullscreen mode

Ok, let me explain this little piece of code:

deviceInfo = CreateObject("roDeviceInfo")
deviceIP = deviceInfo.GetIPAddrs().eth1
Enter fullscreen mode Exit fullscreen mode

Here we are creating "roDeviceInfo" object so we could get IP address of Your Roku by calling "deviceInfo.GetIPAddrs().eth1" on it.
GetIPAddrs() - Returns roAssociativeArray. Each key in the Associative Array is the name of a network interface and the value is the IP-address of the interface.
Normally there will be only one interface in the Associative Array and that's why we call it directly with "GetIPAddrs().eth1".

urlString = "http://" + deviceIP + ":8060/launch/12"
Enter fullscreen mode Exit fullscreen mode

With this string we are creating URL for the launching request.
What is important here is number "12"!
Number "12" is internal channel ID, in my case it's an ID of the Netflix channel.
You can get internal channel ID from the URL of the channel in the Roku channel Store.
Here is how Netflix one looks like:
https://channelstore.roku.com/details/12/netflix
Notice that "12" just after the "/details/" part.
Lets us move on...

request = CreateObject("roUrlTransfer")
request.SetUrl(urlString)
request.AsyncPostFromString(urlString)
Enter fullscreen mode Exit fullscreen mode

This should be straightforward to understand.
We are creating "roUrlTransfer" object, then we have to set URL for the request by passing urlString as argument.
And after that we are calling AsyncPostFromString with urlString as argument.

That is it!
You have just launched Netflix from Your channel! :-)

Just one more thing. Before launching the Netflix channel you will have to have it installed on Your device.
You can do it in "regular/non-developer" way or You can modify urlString variable to instal Netflix from your channel. :-)
You can check Roku Documentation to find more about this: https://developer.roku.com/en-gb/docs/developer-program/debugging/external-control-api.md

Top comments (4)

Collapse
 
danibwuoy profile image
Daniel Yunus

Thanks, is it possible to show a small windowed video player in a game roScreen??

Collapse
 
umitic profile image
Uros Mitic

I do not have personal experience with game development on ROKU platform so I can't provide You with definite answer on this. Judging by the documentation I would say it's not possible but maybe I am not aware of technics that other ROKU game developers would use.
developer.roku.com/en-gb/docs/refe...

Collapse
 
sorka95032 profile image
sorka95032

I heard Roku has removed deep linking from third party channels into third party channels and the API doc referenced here has been removed. Do you know what the status of this is?

Collapse
 
umitic profile image
Uros Mitic

As far as I know, deeplinkig from one channel to another was forbidden for a while now. I think it was forbidden even when this article was created.
To be more precise, if Your channel deeplinks into another one, it will not pass Roku certification. So it's kinda not removed, it's just forbidden, if You would like to publish Your app on Roku store. You can check more on this link, under deeplinking section, chapter 5.3: developer.roku.com/en-gb/docs/deve...

As for the expired ECP documentation link mentioned in the article, I will update it soon but same commands should be present in the new link/docs as well.