Search code examples
youtubenetflixroku

How does YouTube and Netflix push content to Roku?


Using a mobile app, it is possible to "Cast" media from your mobile app to a Roku device on the same network. I do not understand the mechanism being used which allows a remote device (YouTube Android app for example) to cause the selected Roku to open the YouTube channel and start playing the video. I have looked though the Roku developer documentation and am unable to locate any way to launch a channel without the user choosing that channel.


Solution

  • This is one way of doing it:

    1. Use the External Control API to discover the Roku device(s).
    2. Use the query/apps command to ensure that the app you're targeting is installed and/or to obtain the app id. You could also use the install/appID command if you know the app id and you discovered that the app is not installed.
    3. Use the launch/appID to open the app and deep link to specific content. The url should look something like this
      http://<device-ip>:8060/launch/<your-app-id>?contentId=<movie-id-in-your-api>&mediaType=movie.
      Quick note, the install/appID command also launches the app after it's installed the same way the launch/appID command would.
    4. Handle the deep link in your Roku app.

    Example:

    sub main(args as dynamic)
      contentID = args.contentID
      mediaType = args.mediaType
      if contentID <> invalid and mediaType <> invalid
        // Either store the parameters for later use in the app, or make the 
        // requests to your content API right here.
      end if
    end sub
    

    More details on Deep Linking here.