时间:2020年4月27日。
备注:Demo中已经完美解决,没什么问题。
声波抵消时机不好掌握,一旦发生卡顿,极有可能播放两次声音,或者音频错位
StillImage
这种方式效果不佳,会产生奇怪的效果,而且API已经过时。
- (void)captureStillImageAsynchronouslyFromConnection:(AVCaptureConnection *)connection completionHandler:(void (^)(CMSampleBufferRef _Nullable imageDataSampleBuffer, NSError * _Nullable error))handler; 复制代码
- (void)captureOutput:(AVCapturePhotoOutput *)output didFinishProcessingPhotoSampleBuffer:(CMSampleBufferRef)photoSampleBuffer previewPhotoSampleBuffer:(CMSampleBufferRef)previewPhotoSampleBuffer resolvedSettings:(AVCaptureResolvedPhotoSettings *)resolvedSettings bracketSettings:(AVCaptureBracketedStillImageSettings *)bracketSettings error:(NSError *)error; - (void)captureOutput:(AVCapturePhotoOutput *)output willCapturePhotoForResolvedSettings:(AVCaptureResolvedPhotoSettings *)resolvedSettings{ /// 释放声音 AudioServicesDisposeSystemSoundID(1108); } 复制代码
AudioServicesDisposeSystemSoundID(1108); 复制代码
这样就可以了
AudioServicesDisposeSystemSoundID(SystemSoundID inSystemSoundID) 复制代码
/*! @function AudioServicesDisposeSystemSoundID @abstract Allows the System Sound server to dispose any resources needed for the provided SystemSoundID. @discussion Allows the application to tell the System Sound server that the resources for the associated audio file are no longer required. @param inSystemSoundID A SystemSoundID that the application no longer needs to use. */ extern OSStatus AudioServicesDisposeSystemSoundID(SystemSoundID inSystemSoundID) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)) 复制代码
A SystemSoundID that the application no longer needs to use.
应用程序不再需要使用的SystemSoundID。
1108 是非公开的音频ID,有可能被拒,但是有些竞品APP已经使用了这个,应该可以顺利上线。