Phonegap 3.0

编程入门 行业动态 更新时间:2024-10-25 10:26:21
Phonegap 3.0 - 找不到插件(iOS)(Phonegap 3.0 - plugin not found (iOS))

我遇到了以下问题:我正在将旧的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]; } @end

For 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

本文发布于:2023-07-17 13:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1145004.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Phonegap

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!