玩在PhoneGap的地方声音声音、地方、PhoneGap

由网友(为谁画相思)分享简介:我在 WWW 文件夹的.wav 文件。我使用jQuery的有以下code。警报熄灭,但声音不玩了。难道我做错了什么?I have a .wav file in my www folder. I am using jQuery with the following code. The alerts go off but...

我在 WWW 文件夹的.wav 文件。我使用jQuery的有以下code。警报熄灭,但声音不玩了。难道我做错了什么?

I have a .wav file in my www folder. I am using jQuery with the following code. The alerts go off but the sound does not play. Am I doing something wrong?

<script type="text/javascript" charset="utf-8" src="phonegap-0.9.2.js"></script> 
<script type="text/javascript" charset="utf-8" src="jquery.js"></script> 


<script type="text/javascript" charset="utf-8">

$(document).ready(function () {
    window.alert("READY!");
    document.addEventListener("deviceready", onDeviceReady, true);

    function onDeviceReady(){
        window.alert("OK@!");
        var snd = new Media("test.wav");
        snd.play();
    }
});

</script> 

声音就是不玩了。

The sound just does not play.

推荐答案

先给绝对本地路径。例如,

Try giving an absolute local path. E.g.

新媒体(/ android_asset / WWW / test.wav);

new Media("/android_asset/www/test.wav");

这应该工作在Android上。希望他们会解决这个问题的PhoneGap的,因为它是在跨设备支持的东西中的一个错误。

That should work on Android. Hopefully they'll fix this in PhoneGap, as it's something of a bug in the cross-device support.

阅读全文

相关推荐

最新文章