B. Money
B. Money

Reputation: 931

How do I display a YouTube playlist webview?

I want display a YouTube video playlist in a webview in my application. When it loads, it displays on the entire screen of my phone instead of within the layout of my application, which includes a tabhost with three tabs, a title bar, and a status bar. Other links display fine. How do I load YouTube without it taking over my screen?

These are the setting of my webview...

newsfeed = (WebView) findViewById(R.id.webViewnews);
//Enables JavaScript (YouTube)
newsfeed.getSettings().setJavaScriptEnabled(true);
newsfeed.setVerticalScrollBarEnabled(false);

Here is the line of code in question...

} else
    if(selectednewsfeed.contentEquals("4")){
        try{
            //This link display on entire screen
            newsfeed.loadUrl("http://www.youtube.com/watch?v=_3PTjOdMKwY&list=UUBIwq18tUFrujiPd3HLPaGw&feature=plcp"); 

            //This link displays within the layout of my application, but as 
            //title and headline followed by source code
            //newsfeed.loadUrl("http://feeds2.feedburner.com/Maxkeisercom"); 
        }
        catch (Exception e){
            e.printStackTrace();
       }

I also want to know how to display content from FeedBurner in a webview. I want users to be able to read this feed and then access the podcast. How do I make a webview display full HTML?

Upvotes: 0

Views: 1480

Answers (1)

sonu thomas
sonu thomas

Reputation: 2161

I have added this as an answer in Video not playing in Android.

I hope this may help you in a YouTube video to only fill your screen. VideoView and Mediaplayer can play only formats given in their documents named supported media formats.

The YouTube link you gave is for an HTML page.

String url = "your_youtube_link";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

If you want only the video to be viewed from that link, leave all other details in the page. Suppose this is the YouTube link, http://www.youtube.com/watch?v=ZC7ZOGpM2cU&feature=g-logo&context=G233b464FOAAAAAAABAA.

If you parse the source of the YouTube HTML page, you may see this portion:

<link rel="alternate" type="application/json+oembed" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3DZC7ZOGpM2cU&amp;format=json" title="Bigg Boss 5: Juhi Parmar wins Big Boss season 5">
<link rel="alternate" type="text/xml+oembed" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3DZC7ZOGpM2cU&amp;format=xml" title="Bigg Boss 5: Juhi Parmar wins Big Boss season 5">
<meta property="fb:app_id" content="87741124305">
<meta property="og:url" content="http://www.youtube.com/watch?v=ZC7ZOGpM2cU">
<meta property="og:title" content="Bigg Boss 5: Juhi Parmar wins Big Boss season 5">
<meta property="og:description" content="Ntv News: Juhi Parmar wins Bigg Boss 5 - Juhi Parmar wins &#39;Bigg Boss 5&#39;, takes home Rs.1 crore - No kid for now, keen for good work: Juhi Parmar">
<meta property="og:type" content="video">
<meta property="og:image" content="http://i3.ytimg.com/vi/ZC7ZOGpM2cU/hqdefault.jpg">
  <meta property="og:video" content="http://www.youtube.com/v/ZC7ZOGpM2cU?version=3&amp;autohide=1">
<meta property="og:video:type" content="application/x-shockwave-flash">
<meta property="og:video:width" content="396">
<meta property="og:video:height" content="297">
<meta property="og:site_name" content="YouTube">

In this, extract the following.

<meta property="og:video" content="http://www.youtube.com/v/ZC7ZOGpM2cU?version=3&amp;autohide=1">

In this, the http://www.youtube.com/v/ZC7ZOGpM2cU?version=3&amp;autohide=1 link will show it fullscreen.

Similarly, you must extract the part of HTML codes for playlist.

I hope this may help you.

Upvotes: 1

Related Questions