0

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?

4 Answers 4

2

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

android:hardwareAccelerated="true" 
Sign up to request clarification or add additional context in comments.

Comments

1

Easy solution.

Just use Iframe .

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

Comments

0

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.

Comments

0
<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> 

2 Comments

imgur.com/vc1CClG .Still doesnt work for me. I have changed manifest as you had said.
try to check into your Project Properties > Android if your build target is higher that 3.0 or honeycomb

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.