I'm building an app with a WebView
thats supposed to play a video, that's saved locally. Strangely the video player is not working with local video files. It does play videos saved on a server though.
The local files (html and video) are saved in a folder assets/html_test
Here are the files.
HTML
<div class="video-container">
<p>Server</p>
<video poster="video/star.png" controls>
<source src="http://broken-links.com/tests/media/BigBuck.m4v" />
</video>
</div>
<div class="video-container">
<p>local</p>
<video poster="video/star.png" controls>
<source src="BigBuck.m4v" />
</video>
</div>
onCreate in Activity
WebView browser = (WebView) findViewById(R.id.browser);
WebSettings webSettings = browser.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setPluginState(WebSettings.PluginState.ON_DEMAND);
webSettings.setAllowFileAccessFromFileURLs(true);
browser.setWebChromeClient(new WebChromeClient());
browser.loadUrl("file:///android_asset/html_test/video.html");
The first video works, the second one doesn't. I tried different values for the source
, neither of them worked for me:
<source src="BigBuck.m4v" />
<source src="file:///android_asset/html_test/BigBuck.m4v" />
Not sure if this is related, but as soon as I press play, logcat
puts out this:
01-07 12:19:18.073: E/MediaPlayer(32542): error (1, -2147483648)
01-07 12:19:18.073: E/MediaPlayer(32542): Error (1,-2147483648)
I have no clue what the problem is here. Any help would be much appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…