使用PhoneGap的发挥Android的一个WAV [英] using phonegap to play a wav in android

查看:156
本文介绍了使用PhoneGap的发挥Android的一个WAV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的PG应用程序中播放WAV文件,并能正常工作,在iPhone上。

I am trying to play a wav file from my PG application and it works properly on the iPhone.

我看了所有的以下内容:
音频与PhoneGap的工作
http://stackoverflow.com/questions/4159117/how-to-play-song-in-android-phonegap
扮演的PhoneGap本地声音

I have read all the following: audio not working with phoneGap http://stackoverflow.com/questions/4159117/how-to-play-song-in-android-phonegap Playing local sound in phonegap

我使用PGB编译我的应用程序和它使用PG 1.7.0。

I am using PGB to compile my app and its using PG 1.7.0.

我可以计算出如何使其发挥:(

I just can figure out how to make it play :(

我试图用

function getPhoneGapPath() {
    var path = window.location.pathname;
    path = path.substr( path, path.length - 10 );
    return 'file://' + path;
};

var pathToCheerFile=getPhoneGapPath()+ 'sounds/cheer.wav';
console.log('pathToCheerFile=',pathToCheerFile);

return new Media(pathToCheerFile,
        // success callback
        function() {
            console.log("cheer Audio loaded Success");
        },
        // error callback
        function(err) {
            console.log("cheer Audio load Error: " , err);
        },
);

该控制台显示 pathToCheerFile =文件:///android_asset/www/sounds/cheer.wav
后来它显示了助威音频加载错误:与犯错是具有单一属性的对象 code:1

The console is showing pathToCheerFile=file:///android_asset/www/sounds/cheer.wav and later it shows cheer Audio load Error: with err being an object that has a single property code:1.

这是我在做什么任何想法错了?

any ideas on what am I doing wrong ?

推荐答案

删除文件://。从您的路径和应该发挥就好了。

Remove the "file://" from your path and it should play just fine.

这篇关于使用PhoneGap的发挥Android的一个WAV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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