我需要从HTML旁边的www文件夹在iOS上加载mp3。我正在使用phonegap,我的代码与http://docs.phonegap.com/en/2.0.0/cordova_media_media.md.html中的示例基本相同
当我从网络上使用mp3时,它可以在iOS和android上运行,但是如果尝试从www加载mp3,则出现一个窗口,提示我无法使用资源(在ios上)。
我在config.xml中添加了它:
<feature name="http://api.phonegap.com/1.0/device" />
<feature name="http://api.phonegap.com/1.0/file" />
<feature name="http://api.phonegap.com/1.0/media" />
<gap:plugin name="org.apache.cordova.media" />
我正在Windows上通过我的phonegap服务器使用phonegap应用测试ios(http://app.phonegap.com/),然后使用wienre进行调试。该应用程序的其余部分正在运行,只是声音没有开始。
我尝试了几种不同的方法:
"mySound.mp3"
"file://mySound.mp3"
"file:///mySound.mp3"
我也尝试过改用较旧的phonegap版本,但没有运气了。
查看文档(与之前相同的页面),我应该能够仅使用文件名:
order of file search: When only a file name or simple path is provided, iOS searches in the www directory for the file, then in the application's documents/tmp directory:
var myMedia = new Media("audio/beer.mp3") myMedia.play() // first looks for file in www/audio/beer.mp3 then in /documents/tmp/audio/beer.mp3
我花了数小时在互联网上进行测试和测试,但我听不见声音了:/
帮助将不胜感激!
最佳答案
据我所知,iOS使用.wav文件类型。也许您应该将文件类型从.mp3更改为.wav。将以下内容添加到您的config.xml中
<plugin name="Media" value="CDVSound" />
关于android - Phonegap-从www文件夹加载mp3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23592156/