Search the Community
Showing results for tags 'avaudiosession'.
Found 1 result
-
Hi there, I was trying to extend the iOSapi_AVFoundation.pas module, by adding the following function to the AVAudioSession function setCategoryWithOptionsError( category: NSString; withOptions : AVAudioSessionCategoryOptions; error: NSError): Boolean; cdecl; Unfortunately its crashing with an object is nil error, what do I miss here ? I make a local copy of the unit, and the following additions: uses ... const AVAudioSessionCategoryOptionDuckOthers = 2; //S4: add 14.05.20 ... type AVAudioSessionCategoryOptions = NSUInteger; //S4: add 14.05.20 AVAudioSessionClass = interface(NSObjectClass) ['{B24932F9-3C98-44E4-A4F6-0CB58AF7DE8A}'] //S4: 14.05.20 new GUID {class} function sharedInstance: Pointer; cdecl; end; AVAudioSession = interface(NSObject) ['{0B02D5EC-ED09-421A-84BE-6CEE08420E14}'] //S4: 14.05.20 new GUID ... //S4: Addition 14.05.20, the new function I need //[MethodName('setCategory:withOptions:error:')] function setCategoryWithOptionsError( category: NSString; withOptions : AVAudioSessionCategoryOptions; error: NSError): Boolean; cdecl; ... end. This is derived from the function in the Apple reference https://developer.apple.com/documentation/avfoundation/avaudiosession/1616442-setcategory Could be looking in Objective-C like this AVAudioSessionCategoryOptions AVAudioSessionCategoryOptionsNone = 0; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionsNone error:nil]; I want to call it like this LAVAudioSession := TAVAudioSession.Wrap( TAVAudioSession.OCClass.sharedInstance ); //<-- This is original method, it still can be called without exception LRes := LAVAudioSession.setCategory( AVAudioSessionCategoryPlayback, LError); //<-- This is the new method, crash with exception LRes := LAVAudioSession.setCategoryWithOptionsError( AVAudioSessionCategoryPlayback, AVAudioSessionCategoryOptionDuckOthers, LError); Do I have a stupid typo somewhere ? Can the two modules not coexist, because the old one is linked somewhere else ? Shall I use different GUID for the interfaces, or keep the same, to allow static links to find them ? Is the new method not yet in the Rx10.3.3 libraries, but I updated to latest SDK 13.4.1, they should be in there and FMX able to resolve it ? Does the module need to be initialized somehow ? Is there something missing what is needed for correct linkage ? Maybe its too late already, or I'm to blind to see.