Phonegap 3.0 - 找不到插件(iOS)

时间:2013-10-22 10:29:24

标签: ios phonegap-plugins

我遇到了以下问题:我正在将旧的Phonegap 2.7项目升级到Phonegap 3.0,但找不到其中一个插件。

来自PhoneGap的错误:

ERROR: Plugin 'SoundPlug' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
[CDVCommandQueue executePending] [Line 117] FAILED pluginJSON = [
  "SoundPlug1195442045",
  "SoundPlug",
  "getVolume",
  [

  ]
]

www-root中的config.xml:

<feature name="SoundPlug">
    <param name="ios-package" value="SoundPlug" />
    <param name="onload" value="true" />
</feature>
<feature name="SocialSharing">
    <param name="ios-package" value="SocialSharing" />
    <param name="onload" value="true" />
</feature>

问题在于SoundPlug,SocialSharing没有发出任何警告(或者因为它首先加载的SoundPlug失败了。)

在SoundPlug.h中:

#import <AudioToolbox/AudioServices.h>
#import <MediaPlayer/MediaPlayer.h>

#import <Cordova/CDV.h>

@interface SoundPlug : CDVPlugin

- (void) setVolume:(CDVInvokedUrlCommand*)command;
- (void) getVolume:(CDVInvokedUrlCommand*)command;

@end

在SoundPlug.m中:

#import "SoundPlug.h"
#import <MediaPlayer/MediaPlayer.h>

@implementation SoundPlug

- (void) setVolume:(CDVInvokedUrlCommand*)command
{
    MPMusicPlayerController* musicPlayer = [MPMusicPlayerController applicationMusicPlayer];
NSInteger volume = [(NSString *)[command.arguments objectAtIndex:0] integerValue];
    //musicPlayer.volume = 1; // max volume
    //musicPlayer.volume = 0; // min volume (mute)
    musicPlayer.volume = volume * 0.0625; // 1 bar on the overlay volume display
    NSLog(@"Volume set to %f", musicPlayer.volume);
}

-(void) getVolume:(CDVInvokedUrlCommand*)command
{
    MPMusicPlayerController* musicPlayer = [MPMusicPlayerController applicationMusicPlayer];
    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:musicPlayer.volume];
    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}

@end

重要的是:平台是iOS7。 我从头开始重新创建项目并导入文件。

1 个答案:

答案 0 :(得分:0)

我设法通过将插件添加到www目录的外的config.xml 来实现它,所以直接在项目的根目录中。我想我错误地使用了错误的config.xml