声音不打在PhoneGap的应用程序切换到3

声音不打在PhoneGap的应用程序切换到3

本文介绍了声音不打在PhoneGap的应用程序切换到3.1.0后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PhoneGap的应用程序,玩,当你点击图标和声音。它好工作之前,我从升级2.9.0我的PhoneGap Build版本3.1.0到(IOS 7版本支持)。

I have a phonegap app that plays sound when you click and icon. It worked fine before I upgraded my phonegap build version from 2.9.0 to 3.1.0 (ios 7 build support).

下面是我的code

        //Play Audio
        function playAudio(src) {
            if (device.platform == 'Android') {
            src = '/android_asset/www/' + src;
            }
            var media = new Media(src, success, error_error);
            // Set Volume
            media.setVolume('0.7');
            media.play();

        }

        function success() {
            // Default the icon
            $('#sound-icon').removeClass('sound-icon-active').addClass('sound-icon-default');
            //Ga tracking
            ga_storage._trackEvent('Sound Played', 'Play', 'Sound Played succesfully.');

        }

在code神秘地停止了工作。我能在这里失去了一些东西或者是有什么在iOS SDK中更改

The code mysteriously stopped working. Could i be missing something here or is there something that changed in the iOS SDK

编辑:据我从道森劳登投入,PhoneGap的3.X你必须包括不同的插件来访问设备特定功能解决了这个问题。以我为例,我需要添加以下内容:

EDIT : I resolved the issue according to input from Dawson Loudon , in phonegap 3.x you have to include different plugins to access device specific features. In my case I needed to add the following:


  

到config.xml。

to the config.xml.

希望这可以帮助其他人。

Hope this helps someone else.

推荐答案

在从PhoneGap的2.X移动到3.x最大的变化是,所有的API被分成单独的插件。这意味着,任何设备特定的API需要安装一个插件。

When moving from PhoneGap 2.x to 3.x the biggest change is that all of the APIs are broken into separate plugins. This means that any device specific API needs to be installed as a plugin.

看你的code,则需要在设备传媒安装的插件。

Looking at your code, you will need the device and media plugins installed.

有关的PhoneGap构建它添加到 config.xml中

For PhoneGap Build add this to config.xml:

<gap:plugin name="org.apache.cordova.device" version="0.2.8" />
<gap:plugin name="org.apache.cordova.media" version="0.2.8" />

有关CLI运行这些命令(以及重建或prepare):

For CLI run these commands (and rebuild or prepare):

(sudo) cordova plugin add org.apache.cordova.device
(sudo) cordova plugin add org.apache.cordova.media

这篇关于声音不打在PhoneGap的应用程序切换到3.1.0后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 04:58