Sat*_*000 8 javascript cordova phonegap-build
我在使用phonegap在iphone 6上播放mp3时遇到问题.
我从服务器下载一个zip文件,其中包含1个mp3文件和3个图像文件.
所有似乎都正确下载,但我不太确定mp3文件,因为它不会播放.
要测试文件是否存在,我这样做:
<img src="cdvfile://localhost/persistent/audio/1.jpg" alt="" /><br>
<img src="cdvfile://localhost/persistent/audio/2.jpg" alt="" /><br>
<img src="cdvfile://localhost/persistent/audio/3.jpg" alt="" /><br>
<a href="cdvfile://localhost/persistent/audio/1.mp3">MP3HERE</a><br>
<audio class="audio" controls>
<source src="cdvfile://localhost/persistent/audio/1.mp3" type="audio/mpeg">
</audio>
Run Code Online (Sandbox Code Playgroud)
3个图像出现,所以我知道所有的文件必须在那里但是虽然我得到音频播放器它不会播放任何东西,所以我创建了一个类似的MP3也没有播放.
这是我在下面使用的功能:
function downloadAndUnzip() {
var fileTransfer = new FileTransfer();
fileTransfer.download(
"http://myserver.com/test.zip",
"cdvfile://localhost/persistent/audio/test.zip",
function(entry) {
alert("download complete: " + entry.fullPath);
zip.unzip("cdvfile://localhost/persistent/audio/test.zip",
"cdvfile://localhost/persistent/audio/",
function(){
alert('Zip decompressed successfully'); //I get this alert
alert('Checking if test.zip exists');
checkIfFileExists("/audio/test.zip"); //returns that it exists
alert('Checking if 1.jpg exists');
checkIfFileExists("/audio/1.jpg");
alert('Checking if 2.jpg exists');
checkIfFileExists("/audio/2.jpg"); //returns that it exists
alert('Checking if 3.jpg exists');
checkIfFileExists("/audio/3.jpg"); //returns that it exists
alert('Checking if 1en.mp3 exists');
checkIfFileExists("/audio/1.mp3"); //returns that it exists
}
);
},
function(error) {
alert("download error source " + error.source);
alert("download error target " + error.target);
alert("upload error code" + error.code);
});
}
Run Code Online (Sandbox Code Playgroud)
现在,就警报而言,zip文件已成功下载和解压缩.
有关如何解决或解决此问题的任何想法?
| 归档时间: |
|
| 查看次数: |
243 次 |
| 最近记录: |