Search code examples
android-youtube-apiandroid-tv

Android TV embedded youtube 1080p


I want to display some YouTube videos on my Android TV application, I was trying to port something I already have working on a phone, but there I use the YouTube Android API player, that doesn't seem to work on Android TV.

I found this https://code.google.com/p/gdata-issues/issues/detail?id=6998 so it looks like I'm not alone.

I added a WebView and I can display a video but I can't get full hd resolution, is that possible with embedded videos?


Solution

  • YouTube Player Full API is not available on Android TV but developers can currently use the YouTube intent as follows.

        String videoId = "dQw4w9WgXcQ";
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + videoId));
        intent.putExtra("force_fullscreen", true);
        intent.putExtra("finish_on_ended", true);
        startActivity(intent);
    

    This will use YouTube app to play videos. The force_fullscreen=true removes navigation to related videos while the finish_on_ended=true returns to calling app when video is done.

    You may also use

        Intent intent = YouTubeIntents.createPlayVideoIntentWithOptions(this, videoId, true, false);
    

    if you download the YouTubeAndroidPlayerAPI:

    https://developers.google.com/youtube/android/player/downloads/

    and include the jar file in your project