【发布时间】:2017-04-09 10:35:48
【问题描述】:
我正在尝试更改 Cordova 插件,以便可以从 javascript 更改 iOS 音乐类别,但我在 Cordova 构建日志中收到警告
知道我的代码有什么问题吗?第一个参数有效,第二个无效
audio.setCategory('AVAudioSessionCategoryAmbient',
'AVAudioSessionCategoryOptionMixWithOthers')
和 iOS 部分:
- (void) setCategory:(CDVInvokedUrlCommand *)command {
NSArray* arguments = command.arguments;
NSString *category = [arguments objectAtIndex:0];
NSString *options = [arguments objectAtIndex:1];
[[AVAudioSession sharedInstance] setCategory:category withOptions:options error:nil];
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] callbackId:command.callbackId];
}
我收到以下警告
/project/koeriersapp/Plugins/cordova-plugin-nativeaudio/NativeAudio.m:67:71: 警告:指向整数转换的不兼容指针发送'NSString *__strong' 到“AVAudioSessionCategoryOptions”类型的参数(又名“枚举 AVAudioSessionCategoryOptions”)[-Wint-conversion] [[AVAudioSession sharedInstance] setCategory:category withOptions:options error:nil]; ^~~~~~~~~~~~ 在从导入的模块'AVFoundation'中 /project/koeriersapp/Plugins/cordova-plugin-nativeaudio/NativeAudio.h:11: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.1.sdk/System/Library/Frameworks/AVFoundation.framework/Frameworks/AVFAudio.framework/Headers/AVAudioSession.h:364 :85: 注意:在此处将参数传递给参数“选项” - (BOOL)setCategory:(NSString *)category withOptions:(AVAudioSessionCategoryOptions)options error:(NSError **)outError NS_AVAILABLE_IOS(6_0); ^
【问题讨论】:
-
仅供参考,phongap 已弃用,请使用
cordova名称
标签: javascript ios cordova