Can't play audio in Android device

孤人 提交于 2019-12-11 08:50:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!