This is just an internet way to achieve the goal of playing audio from an html file
use Mediaplayer ( http://developer.android.com/reference/android/media/MediaPlayer.html ) for Android to play sound. you can call the android function from javascript that you wrote in the HTML file.
This is an example of how you can call a function written in a java file from javascript code
WebView webView = (WebView) findViewById(R.id.webview); webView.addJavascriptInterface(new WebAppInterface(this), "Android"); -------------------------------- public class WebAppInterface { Context mContext; WebAppInterface(Context c) { mContext = c; } @JavascriptInterface public void showToast(String toast) { Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show(); } } --------------------------- java sript code <input type="button" value="Say hello" onClick="showAndroidToast('Hello Android!')" /> <script type="text/javascript"> function showAndroidToast(toast) { Android.showToast(toast); } </script>
This way you call the sound from the Android code.
source share