3

I am developing epub reader for Android devices. Audio and video doesn't play on webview from loaded HTML page. It seems like audio and video tags are not working. I have seen some solution like this:<video src="soundfile.mp3" onclick="this.play();"></video>. But how I can change particular (<audio>) tag from loaded HTML file.

This is my webview settings:

final WebView webView = (WebView) findViewById(R.id.webView);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setPluginsEnabled(true);
    webView.getSettings().setPluginState(PluginState.ON);
    webView.setWebViewClient(new MyCustomWebViewClient());
    webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    webView.loadUrl("about:blank");
    webView.loadUrl("file:///mnt/sdcard/myfolder/epubfile/OPS/02-audioDemo.xhtml");

What I have do for playing audio and video on my weview. Please help me to overcome this.

4

2 回答 2

0

首先:使用 Environment.getExternalStorageDirectory() 因为 /mnt/sdcard/ 在所有 android 设备上都不能一直工作。还有 getExternalStorageState() 这会检查媒体是否可用。

也可能不是这个,因为我目前没有强制执行,但尝试添加读取 SD 卡的权限:

首先检查并回复。

于 2013-04-13T10:13:19.360 回答
0

请将此扩展的 HTML5 Webview 用于那些类型的 HTML5 音频和视频。https://code.google.com/p/html5webview/

于 2013-04-19T06:59:28.273 回答