YouTube launches its native Player API for Android, enabling in-app video plays, ad support, more


At Google I/O 2012, YouTube announced that it was releasing a native Player API for Android. Six months later, it has finally arrived, although it’s still being treated as an experiment. With this API, developers are now able to embed and play YouTube videos within their apps while also receiving support for YouTube ads, getting closed caption displays, and more.

With YouTube’s Android Player API, the goal was to find a way to bring the service to Android devices. Yes, there is a YouTube mobile app, but it’s much more than that. Rather it’s about taking advantage of the fact that there are millions of videos on the network and being able to incorporate them in a way that’s easy and doesn’t force users away from the app they’re using.

Available for those apps on devices with Android 2.2 (that’s Froyo) or newer, the restriction that YouTube has on its use is only the developer’s “imagination” and, of course, YouTube’s Terms of Service. In its post announcing the release, the company said the API is well-documented and there are instructions on how to include the API client library in any application:

These instructions explain how to include the YouTubeAndroidPlayerApi.jar client library in your Android application. The library is supported on Android devices running version 4.2.16 or newer of the Android YouTube app.

You can use the YouTubeApiServiceUtil class’ isYouTubeApiServiceAvailable method to confirm that a device is compatible.

For a simple embed, use the YouTubeStandalonePlayer. To build a more sophisticated user interface, try theYouTubePlayerView or the YouTubePlayerFragmentFragments can help create an engaging experience as shown in the Video Wall app example.

Developers who integrate this API will find it comes with several features, including support for fullscreen and changes to orientation, closed captions displaying that will benefit those with hearing difficulties and those who don’t have headphones or want sound on their device, and support for YouTube ads (added monetization opportunity). Programmatic access that’s available with other Player APIs is also included.

Some apps that are already using this new API include Flipboard (which just launched its Android tablet version), BuzzFeed, 9×, SoundTracking, and Skimble.

YouTube has set up several code examples for developers to get started with the API and documentation is available on its site as well.

Photo credit: ERIC PIERMONT/AFP/Getty Images

Read next: Google finds its design voice on iOS