2013-02-15 106 views
0

嗨,我想在android中嵌入youtube視頻。 這就是在屏幕上顯示出來 - http://imgur.com/5YEVq24android webview -youtube嵌入不工作

這是我的WebView代碼

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

圖顯示了罰款,但圖像下面的視頻顯示不出來,它也不當我玩點擊它。

任何機構可以幫助我嗎?

回答

0

您是否在您的webview中啓用了JavaScript? 如果沒有 試試這個,我在這裏啓用JavaScript

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

這是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> 

另外還有一個問題是,視頻可以不由於硬件資源有限,在某些設備上播放。

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

試圖把 「的xmlns:工具=」 http://schemas.android.com/tools」

和android:硬件加速= 「你的清單

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

http://imgur.com/vc1CClG。仍然不適合我。正如你所說,我改變了艙單。 – 2013-02-15 10:00:07

+0

嘗試檢入您的項目屬性> Android,如果您的構建目標高於3.0或蜂窩 – Cjames 2013-02-16 04:55:32

2

真」這個小除了在清單中的應用程序級別的伎倆:

android:hardwareAccelerated="true" 
1

簡單的解決方案

只需使用Iframe。

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