我遇到了以下问题:我正在将旧的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;@结束
在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。 我从头开始重新创建项目并导入文件。
I got the following issue: I'm upgrading an old Phonegap 2.7 project to Phonegap 3.0 but one of the plugins isn't found.
The error from 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", [ ] ]The config.xml in the www-root:
<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>The problem lies with SoundPlug, the SocialSharing doesn't give any warning (or that's because it fails on SoundPlug who is loaded first).
In 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
In 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]; } @endFor what it matters: the platform is iOS7. I recreated the project from scratch and imported the files.
最满意答案
我设法通过将插件添加到www目录之外的config.xml来实现它,所以直接在项目的根目录中。 我想我错误地使用了错误的config.xml
I managed to get it working by adding the plugins to the config.xml outside the www directory, so the one directly in the root of the project. I guess I mistakenly used the wrong config.xml
更多推荐
SoundPlug,musicPlayer,command,The,Phonegap,电脑培训,计算机培训,IT培训"/> <me
发布评论