玩在PhoneGap的地方声音 [英] Playing local sound in phonegap

查看:83
本文介绍了玩在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 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.

这篇关于玩在PhoneGap的地方声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆