title: Playing sound in WebView from JavaScript
body: <p>I'm trying to play sound from JavaScript code loaded to WebView from assets:</p>
  
  <pre><code>WebView web_view = (WebView) findViewById(R.id.web_view);
  web_view.getSettings().setJavaScriptEnabled(true);
  web_view.setWebChromeClient(new WebChromeClient());
  web_view.loadUrl("file:///assets/www/index.html");
  </code></pre>
  
  <p>I tried all combinations of following ways how to play audio with OGG, MP3 and WAV files, the JavaSrcipt code is in assets/www/js/play.js:</p>
  
  <pre><code>audio = new Audio("../audio/sound.mp3");
  audio.load();
  audio.play();
  
  audio = new Audio("./audio/sound.mp3");
  audio.load();
  audio.play();
  
  audio = new Audio("audio/sound.mp3");
  audio.load();
  audio.play();
  
  audio = new Audio("file:///android_asset/www/audio/sound.mp3");
  audio.load();
  audio.play();
  
  audio = new Audio();
  audio.src = document.getElementById("audio_tag").src;
  audio.load();
  audio.play();
  </code></pre>
  
  <p>Where audio_tag is <code>&lt;audio id="audio_tag" src="audio/sound.mp3" preload="auto"&gt;&lt;/audio&gt;</code>, also tried with all combinations of paths and formats.</p>
  
  <p>But the sound is not playing and only clue what may be wrong is following general error:</p>
  
  <blockquote>
    <p>E/MediaPlayer(1530): error (1, -2147483648)</p>
  </blockquote>
  
  <p>Guessing from this info message, the path to audio file should be correct for second trough fifth case:</p>
  
  <pre><code>I/StagefrightPlayer(33): setDataSource('file:///android_asset/www/audio/sound.mp3');
  </code></pre>
  
  <p>Although this question may be considered as duplicate of 
  <a href="https://stackoverflow.com/questions/3795276/android-webview-playing-audio-with-javascript">Android WebView playing audio with javascript</a> and the answer is not helping anyhow since shouldOverrideUrlLoading is never called, I'm trying to specify this problem more precisely here.</p>
  
  <p>Do you have any clue what may be wrong or how to find out what is it?</p>
  
  <p>Thank you.</p>
  
  <p>Edit: Testing in Galaxy Gio with Android 2.3 gives me different set of errors though:</p>
  
  <blockquote>
    <p>02-06 17:15:13.829: V/PlayerDriver(95): AddToScheduler    02-06
    17:15:13.829: V/PlayerDriver(95): PendForExec    02-06 17:15:13.829:
    V/PlayerDriver(95): OsclActiveScheduler::Current    02-06
    17:15:13.829: V/PlayerDriver(95): StartScheduler    02-06
    17:15:13.829: V/PVPlayer(95): send PLAYER_SETUP    02-06 17:15:13.829:
    V/PlayerDriver(95): Send player code: 2    02-06 17:15:13.829:
    V/PlayerDriver(95): CommandCompleted    02-06 17:15:13.829:
    V/PlayerDriver(95): Completed command PLAYER_SETUP status=PVMFSuccess 
    02-06 17:15:13.829: V/PVPlayer(95):
    setDataSource(file:///android_asset/www/audio/sound.mp3)    02-06
    17:15:13.839: V/PVPlayer(95): prepareAsync    02-06 17:15:13.839:
    V/PVPlayer(95):   data source =
    file:///android_asset/www/audio/sound.mp3    02-06 17:15:13.849:
    V/PlayerDriver(95): Send player code: 3    02-06 17:15:13.849:
    V/PlayerDriver(95): handleSetDataSource    02-06 17:15:13.849:
    V/PlayerDriver(95): handleSetDataSource- scanning for extension<br>
    02-06 17:15:13.849: V/PlayerDriver(95): HandleInformationalEvent:
    PVMFInfoErrorHandlingStart    02-06 17:15:13.849: V/PlayerDriver(95):
    HandleInformationalEvent: type=26 UNHANDLED    02-06 17:15:13.849:
    W/MediaPlayer(4361): info/warning (1, 26)    02-06 17:15:13.849:
    V/PlayerDriver(95): CommandCompleted    02-06 17:15:13.849:
    V/PlayerDriver(95): Completed command PLAYER_SET_DATA_SOURCE
    status=PVMFErrNotSupported    02-06 17:15:13.849: E/PlayerDriver(95):
    Command PLAYER_SET_DATA_SOURCE completed with an error or info<br>
    PVMFErrNotSupported    02-06 17:15:13.849: E/MediaPlayer(4361): error
    (1, -4)    02-06 17:15:13.849: V/PVPlayer(95): run_init s=-2147483648,
    cancelled=0    02-06 17:15:13.849: V/PlayerDriver(95):
    HandleInformationalEvent: PVMFInfoErrorHandlingComplete    02-06
    17:15:13.849: W/PlayerDriver(95): PVMFInfoErrorHandlingComplete<br>
    02-06 17:15:13.939: I/MediaPlayer(4361): Info (1,26)    02-06
    17:15:13.939: E/MediaPlayer(4361): Error (1,-4)    02-06 17:15:13.939:
    V/PVPlayer(95): reset    02-06 17:15:13.939: V/PlayerDriver(95): Send
    player code: 18    02-06 17:15:13.939: V/PlayerDriver(95):
    handleCancelAllCommands    02-06 17:15:13.939: V/PlayerDriver(95):
    CommandCompleted    02-06 17:15:13.939: V/PlayerDriver(95): Completed
    command PLAYER_CANCEL_ALL_COMMANDS status=PVMFSuccess    02-06
    17:15:13.939: V/PlayerDriver(95): Send player code: 11    02-06
    17:15:13.939: V/PlayerDriver(95): handleReset    02-06 17:15:13.939:
    V/PlayerDriver(95): CommandCompleted    02-06 17:15:13.939:
    V/PlayerDriver(95): Completed command PLAYER_RESET status=PVMFSuccess 
    02-06 17:15:13.939: V/PlayerDriver(95): Send player code: 17    02-06
    17:15:13.939: V/PlayerDriver(95): handleRemoveDataSource    02-06
    17:15:13.939: V/PlayerDriver(95): CommandCompleted    02-06
    17:15:13.939: V/PlayerDriver(95): Completed command
    PLAYER_REMOVE_DATA_SOURCE status=PVMFSuccess    02-06 17:15:13.939:
    V/PlayerDriver(95): remove datasource complete    02-06 17:15:13.939:
    V/PVPlayer(95): unmap file</p>
  </blockquote>