Use Youtube API on Android TV

I want to play YouTube videos in Android TV APP. I am also working on an Android phone / APP tablet, and I was able to use the Youtube Android API to play the video. But when I try to use the same API on Android TV, it gives me an error ("This application will not work if you do not update YouTube"), but my YouTube is updated.

I found this problem in the tracker of tracking problems with the YouTube Android player, this is the same problem I encountered here, so I want to find out if anyone has a solution or know a different version of the API that might work. I am using the Android Player API v1.2.2 for YouTube Player.

I know that I can open youtube through Intent, but I need to use the YouTube API to display the video.

+5
source share
3 answers

I have the same understanding with you. The YouTube API only works with the YouTube smartphone app, not the YouTube Android TV. I think that if you plan to publish the Android TV application, you will not be able to use the YouTube Android Player API, except for Intent. As you should expect, the user will install the YouTube Android TV app.

For reference,

  • The current behavior of the Android Player API for Android is presented here .
  • The source code that YouTube Intent uses to play YouTube videos on Android TV.
+3
source

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

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

To interact between your JS and Java code, look at a project like this: https://github.com/Fleker/WebGameBridge.js to use the WebView API,

As for data acquisition, there is also a web API for this, with which you can access through your WebView.

+3
source

I created YoutubeTV library , a wrapper for YouTube API reference API for iframe attachments

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

In addition, YoutubeTvFragment contains YoutubeTvView with a media control panel ( PlaybackOverlayFragment )

+2
source

Source: https://habr.com/ru/post/1245646/


All Articles