Derek S
Derek S

Reputation: 51

Embedding a youtube video into android app using eclipse?

I'm trying to figure out how to embed youtube videos into android using eclipse. I would prefer to use the chromeless player, but at this point it's not necessary.

Any help on how to do this would be greatly appreciated.

Upvotes: 5

Views: 11879

Answers (3)

stevyhacker
stevyhacker

Reputation: 1877

If you want to play the video from inside the application to really embed it you can use WebView and load it with just iframe of that youtube video.

WebView webview;
webview.getSettings().setJavaScriptEnabled(true);
webview.loadData("<iframe src=\"http://www.youtube.com/watch?v=hZ4sDn89P04\"></iframe>","text/html","utf-8");

Upvotes: 0

sani_ok
sani_ok

Reputation: 79

YouTube API for Android is availible now. Following this link, you will find a sample how to use YouTube API under Android.

Using YouTubePlayerView you can play video from youtube in your activity. But it is not possible to change default controls.

Upvotes: 3

Trasplazio Garzuglio
Trasplazio Garzuglio

Reputation: 3585

The easiest way to embed a Youtube video is to use an intent to fire the Youtube application, like this:

String video_path = "http://www.youtube.com/watch?v=opZ69P-0Jbc";
Uri uri = Uri.parse(video_path);

// With this line the Youtube application, if installed, will launch immediately.
// Without it you will be prompted with a list of the application to choose.
uri = Uri.parse("vnd.youtube:"  + uri.getQueryParameter("v"));

Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

Upvotes: 8

Related Questions