0
我得到了以下問題:我正在將Phonegap 2.7的舊項目升級到Phonegap 3.0,但找不到其中一個插件。Phonegap 3.0 - 找不到插件(iOS)
從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根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。 我重新創建了項目並導入了文件。
我在啓動畫面和iOS應用瀏覽器中遇到了類似的問題。我最終做的只是刪除了項目並重新添加了一次,然後一切正常。 – mhartington
我設法通過將插件添加到config.xml * outside * www目錄中,所以直接在根目錄該項目。仍然必須等到我可以標記這是正確的... – user2740112