GOOD NEWS

GOOD NEWS
Ask For The Truth...

Tuesday, July 10, 2012

How to Embed Youtube Videos using Object tag in Android?

How to Embed Youtube Videos using Object tag in Android?:
I am trying to embed a youtube video on a xml file for my application.

Following is my XML file:

<?xml version="1.0" encoding="utf-8"?>
<WebView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/tour_webview"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">  
  <object 
    width="480" 
    height="330">
    <param 
        name="movie" 
        value="http://www.youtube.com/v/tjxpMhGwXH4?version=3&amp;hl=pt_BR&amp;rel=0">   
    </param>
    <param 
    name="allowFullScreen" 
    value="true">
</param>
<param 
    name="allowscriptaccess" 
    value="always">
</param>
<embed 
    src="http://www.youtube.com/v/tjxpMhGwXH4?version=3&amp;hl=pt_BR&amp;rel=0" 
    type="application/x-shockwave-flash" 
    width="480" 
    height="330" 
    allowscriptaccess="always" 
    allowfullscreen="true" />
</object>  
</WebView>

Following is my java file:

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tours_04);
    WebView wv = (WebView)findViewById(R.id.tour_webview);
    wv.getSettings().setPluginsEnabled(true);
    wv.getSettings().setJavaScriptEnabled(true);
    wv.getSettings().setAllowFileAccess(true);
    wv.loadUrl("http://www.youtube.com/watch?v=tjxpMhGwXH4");
    setContentView(wv);
}

Logcat says:

Caused by abdroid.View.InflateException: Binary XML file line #7:Error inflating class object

Help Needed!

No comments:

Post a Comment