简体   繁体   English

Phonegap Build播放本地音频

[英]Phonegap Build play local audio

I would like to play a song with phonegape build. 我想播放带有phonegape版本的歌曲。 My problem is that in an phonegap build project, all files are in the same folder. 我的问题是在phonegap构建项目中,所有文件都在同一文件夹中。 So that i dont now what the correct path is to my soundfile, included in the project. 因此,我现在不知道我的声音文件(包含在项目中)的正确路径是什么。 It worked good with an url like shown in your examples. 如您的示例中所示,它与url一起使用效果很好。 I tried diffrent paths to access the audio file for example : 我尝试了不同的路径来访问音频文件,例如:

"/android_asset/www/test.mp3" 
"/asset/test.mp3" 
"test.mp3" 

I have no clue why it wont worked, here i show my problem on fiddle: http://jsfiddle.net/b7BPV/ Thanks for help and greetings from germany!!! 我不知道为什么它不起作用,在这里我用小提琴展示我的问题: http : //jsfiddle.net/b7BPV/感谢德国的帮助和问候! Your awesome!! 你真棒!!

This would be the location of test.mp3 if you have the file located in your www folder 如果您的文件位于www文件夹中,则这将是test.mp3的位置

src="test.mp3" 

the change you require for your code is 您对代码进行的更改是

<a href="#" class="btn large" onclick="playAudio('test.mp3');">Play Audio</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM