I want to play youtube videos in my Android TV APP. I am also working on a Android phone/tablet APP and I was able to use Youtube Android API to play videos. But when I try
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,
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
)