Use Youtube API in Android TV

The YouTube playback API may not work on Android TV, but you can always implement your own playing mechanism in-app. Take a look at YouTube's web player API: https://developers.google.com/youtube/iframe_api_reference

You can load a WebView in your app and from there add an iframe and JS logic to integrate with your controller.

To interface between your JS and Java code, take a look at a project like this: https://github.com/Fleker/WebGameBridge.js for how to use the WebView APIs.

In terms of getting data, there are also web APIs for this that you can access through your WebView.


I've created YoutubeTV library, a wrapper for YouTube Player API Reference for iframe Embeds

It provides a YoutubeTvView that embeds a Webview with Youtube iframe with all Javascript API available from this view.

Also, YoutubeTvFragment holds a YoutubeTvView with a media control bar (PlaybackOverlayFragment)


I have the same understanding with you. YouTube API works only smartphone YouTube app and not for Android TV YouTube app. I think if you are thinking of publishing Android TV app, you cannot use YouTube Player Android API except Intent for now. Because you should expect user installs Android TV YouTube app.

For reference,

  • Current behavior of YouTube Android Player API is summarized here.
  • Source code which uses YouTube Intent to play YouTube video in Android TV.