问题
I want to make something like this :
<audio controls>
<source src="media/blablabla.mp3" type="audio/mpeg"></source>
</audio>
I run my app on local host :8080/console and it worked (The music can played). But when I run that apps on my device, the music can't played.
My Device OS is Android 4.1.2
回答1:
See this question for an answer: IBM Worklight 6.1 - Unable to play a local media file using Cordova
Copy-paste of my answer:
... for playing a local media file, you need to provide the full path to the media file's location where it'll be in the generated Android project. For example, if you create a
common\audio
folder in the Worklight application and place a .mp3 file in it, you need to use the following path (in the HTML or JavaScript, or however you'd like...):<a href="#" onclick="playAudio('/android_asset/www/default/audio/myMediaFile.mp3');">Play Audio</a>
Sample project: Android Cordova Media API
来源:https://stackoverflow.com/questions/17774559/cant-play-audio-in-android-device