Android TV embedded youtube 1080p

2.4k views Asked by At

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?

3

There are 3 answers

0
ssgg Google Developer Platform On BEST ANSWER

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

3
Michael Phaedok On

I tried loading into a webview and I get an error:

I/chromium﹕ [INFO:CONSOLE(12)] "The key "target-densitydpi" is not supported.", source: https://m.youtube.com/watch?vq=hd1080&v=VidV0n-3a_U (12)

If I use this it works:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));

0
Verma On

You would just need to have video URL telling to play in resolution you want:

String url = "https://www.youtube.com/v/VIDEOID?version=3&vq=hd1080";

WebView myWebView = (WebView) this.findViewById(R.id.webView1);

view.loadUrl(url);