raghu_3
raghu_3

Reputation: 1899

android webview -youtube embed not working

Hi i am trying to embed an youtube video in android. This is what shows up on screen -https://i.sstatic.net/rpjWS.jpg

This is my code for webview

<img src="illustration.jpg" />
<video src="http://www.youtube.com/watch?v=dvWy9NXiZZI"  width="320" height="240" autobuffer controls onclick="this.play();"/>

The image shows up fine but the video below the image doesn't show up , neither does it play when i click on it.

Can any body please help me out?

Upvotes: 0

Views: 2204

Answers (4)

aaaa
aaaa

Reputation: 11

Easy solution.

Just use Iframe .

<iframe width="350" height="240" src="https://www.youtube.com/embed/VIDEO_ID" frameborder="0" allowfullscreen></iframe>

Upvotes: 1

Yogev
Yogev

Reputation: 1363

This small addition to the Application level in the manifest does the trick:

android:hardwareAccelerated="true"  

Upvotes: 2

Cjames
Cjames

Reputation: 1872

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.house"
android:versionCode="1"
android:versionName="1.0" xmlns:tools="http://schemas.android.com/tools">

try to put "xmlns:tools="http://schemas.android.com/tools"

and android:hardwareAccelerated="true" in your manifest

<activity android:name="Main_Webview" android:hardwareAccelerated="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:configChanges="orientation|keyboardHidden"></activity>     

Upvotes: 0

Amalan Dhananjayan
Amalan Dhananjayan

Reputation: 2287

did you enable javascript in your webview? if not try this, here I am enabling javascript

WebView web=(WebView) findViewById(R.id.webView1);
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("http://www.youtube.com/watch?v=dvWy9NXiZZI");

This is the xml

main.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<android.webkit.WebView
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
</android.webkit.WebView>

Also there is an issue that the videos cannot be played in some devices due to limitted hardware resources.

Upvotes: 0

Related Questions