I created a ContentProvider. It exports files within my assets/ directory. I'm using content:// urls to access the exported content in a WebView.
The following HTML works as expected:
<img src="content://<provider-name>/test.jpg">
I'm trying to use the content provider for mp3 audio files:
<div id='player'></div>
<script>
url = "content://<provider-name>/test.mp3";
var audio = document.createElement('audio');
audio.src = url;
audio.controls = "controls";
document.getElementById("player").appendChild(audio);
</script>
I'm getting the following error message.
E/MediaPlayer(24120): Unable to to create media player
E/HTML5Audio(24120): couldn't load the resource: content://.../test.mp3 exc: java.io.IOException: setDataSource failed.: status=0x80000000
I tried the Android SDK 8 and 10 without success. I'm not seeing any access to my ContentProvider in the log. It looks like accessing content from audio-tags is not possible within a WebView. It seems strange, since the following code works as expected:
MediaPlayer player = MediaPlayer.create(this,
Uri.parse("content://<provider-name>/test.mp3")
);
player.start();
How can I play audio files from a ContentProvider within a WebView?