I tested YouTube Android Player API on Android TV devices. Sadly it is not working well with Android TV’s YouTube app (“YouTube for Android TV”). Only YouTube App Launcher Intents works well for now (2016.1.14).
- 1 YouTube Android Player API
- 2 Testing Sample applictions
- 3 Implementing YouTube video playback on Android TV app?
YouTube Android Player API
YouTube Android Player API is an official library on Google Developers web site, which enables us to integrate YouTube functionality into our (third party’s) Android apps. We can control YouTube video/playlist playback from our app, and customize playback view using YouTube Android Player API.
YouTube app must be installed on user’s device
As written in the official page,
How it works
The API client library interacts with a service that is distributed as a part of the YouTube app for the Android platform.
the API is calling the API defined in YouTube app. Therefore, when the app uses YouTube Android Player API, the application users must have YouTube app installed on their devices.
If YouTube app is not installed yet…
Don’t worry. In that case Goole play store app suggest users to install/enable/update YouTube app when the API is called.
When the YouTube app is disabled on user’s device,
API shows dialog to enable YouTube App.
* In terms of the Android TV, almost all the devices pre-installs YouTube app. At least I know that Nexus Player and SONY BRAVIA Android TV, which are the most major Android TV devices for now, have YouTube app pre-installed. So this restriction may not be a problem.
Testing Sample applictions
Sample applications are available from official page, you can download API jar files together with the sample source code. Build by yourself using your own YouTube API key (it is troublesome that you need to register your own YouTube API key even if this is testing, though), and you can see the each features provided by this API.
- Video Wall
- Video List
- Simple PlayerView
- Simple PlayerFragment
- Custom Player Controls
- Custom Fullscreen handling
- Overlay ActionBar Demo
- Standalone Player
- YouTube App Launcher Intents
When I tested these sample applications on Android TV, all functions do not work except for YouTube App Launcher Intents.
Concretely, if I try to navigate each features, YouTube App update dialog appears even if the YouTube App for Android TV is latest version. (Tested with “YouTube for Android TV” app version 1.3.8)
But I can test these features fine with Android phone, so I will list up each samples anyway.
Sample demo showing a flipping card, one card will start playing video from YouTube playlist.
YouTubeThumbnailViews with adapter to show list of YouTube videos.
YouTubePlayerView to play YouTube video.
YouTubePlayerFragment to play YouTube video. Appearance to the user looks same with
Custom Player Controls
The sample code how to control
YouTubePlayer programatically from your app.
Custom Fullscreen handling
Sample code for how to handle fullscreen video playback.
Overlay ActionBar Demo
Demo for controlling Action Bar. Action bar will automatically fade away when the video is player with full screen.
It demonstrates the usage of
You can start YouTube player in a separate Activity.
YouTube App Launcher Intents
This is the only available feature for Android TV app for now, and even not all but only major functionality is supported. By using YouTube Android Launcher Intents, you can launch YouTube app with specific page. But for users, they don’t usually notice application is changed. It just looks seemlessly navigated to YouTube video playback etc.
Available Intents for Android TV are following.
- Play Video: create intent to start video playback by specifying YouTube Video Id
- Open Playlist: create intent to open playlist page by specifying YouTube Playlist Id
- Play Playlist: create intent to start playlist video playback by specifying YouTube Playlist Id
- Open User: create intent to show user’s page by specifying YouTube user Id
Above picture is a example after clicking “Open User” on Android TV. It will launch user’s page of “Google”.
Implementing YouTube video playback on Android TV app?
So far, only using YouTube Intents is available. It means that you cannot embed YouTube video player view in your application, but it is only possible to launch YouTube app to do the desired job.
I’m going to write a post for YouTube video playback on Android TV app soon.