1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- //
- // AudioRecorder.h
- // mask
- //
- // Created by 翟玉磊 on 2019/1/3.
- // Copyright © 2019 翟玉磊. All rights reserved.
- // 功能描述 封装声音录制与播放
- #import <Foundation/Foundation.h>
- NS_ASSUME_NONNULL_BEGIN
- typedef void(^DetectionVoiceBlock)(double lowPassResults, double currentTime);
- @interface AudioRecorder : NSObject
- #pragma mark - 文件操作
- /// 录音文件保存路径
- NSString *GetFilePathWithDate(void);
- /// 获取文件名(包含后缀,如:xxx.acc;不包含文件类型,如xxx)
- NSString *GetFileNameWithFilePath(NSString *filePath, BOOL hasFileType);
- /// 获取文件大小
- long long GetFileSizeWithFilePath(NSString *filePath);
- /// 删除文件
- void DeleteFileWithFilePath(NSString *filePath);
- #pragma mark - 录音
- /// 实例化单例
- + (AudioRecorder *)shareManager;
- #pragma mark - 音频处理-录音
- /// 开始录音
- - (void)audioRecorderStartWithFilePath:(NSString *)filePath;
- /// 停止录音
- - (void)audioRecorderStop;
- /// 录音时长
- - (NSTimeInterval)durationAudioRecorderWithFilePath:(NSString *)filePath;
- /// 音量回调以及当前录制时间
- @property (nonatomic, readwrite, copy) DetectionVoiceBlock detectionVoiceBlock;
- #pragma mark - 音频处理-播放/停止
- /// 音频开始播放或停止
- - (void)audioPlayWithFilePath:(NSString *)filePath;
- /// 音频播放停止
- - (void)audioStop;
- @property (nonatomic, assign) BOOL playing;
- /*
- * 播放完成回调
- */
- @property (nonatomic, copy) void (^playerFinished)();
- - (void)clear;
- @end
- NS_ASSUME_NONNULL_END
|