このリンクhttp://www.broken-links.com/tests/video/をwebviewから開こうとしていますが、まったく運がありませんでした。実際には、私の携帯電話(android 2.3)のWebブラウザーで動作し、ビデオを再生できます。しかし、webviewを使用してテストアプリで試した場合は機能しません。Webサイトは読み込まれますが、ビデオは利用できません。
Webブラウザーは完全に機能するため、Webビューがビデオタグをサポートしていないわけではありませんが、どこが間違っているのかわかりません。
親切に助けてください。ありがとう!
私の簡単なコードは
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String fileUrl="http://www.broken-links.com/tests/video/";
WebView wv=(WebView)findViewById(R.id.webView1);
WebSettings settings=wv.getSettings();
settings.setAllowFileAccess(true);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setBuiltInZoomControls(true);
settings.setJavaScriptEnabled(true);
settings.setPluginsEnabled(true);
wv.setWebChromeClient(new WebChromeClient(){
@Override
public boolean onConsoleMessage(
ConsoleMessage consoleMessage) {
Log.e("viewengine.createWebView()",
consoleMessage.toString());
return true;
}
});
wv.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(
WebView view,String url) {
return true;
}
});
wv.setHorizontalScrollBarEnabled(false);
wv.setVerticalScrollBarEnabled(false);
wv.loadUrl(fileUrl);
}
}
とマニフェスト
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nsoft.test18"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.nsoft.test18.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
とレイアウト
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" />
</RelativeLayout>