2025-11-21 16:17:05 +08:00
|
|
|
|
//
|
|
|
|
|
|
// QXAudioRecorderView.h
|
|
|
|
|
|
// QXLive
|
|
|
|
|
|
//
|
|
|
|
|
|
// Created by 启星 on 2025/11/13.
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
typedef NS_ENUM(NSInteger, AudioRecorderState) {
|
|
|
|
|
|
AudioRecorderStateReady, // 准备状态
|
|
|
|
|
|
AudioRecorderStateRecording, // 录制中
|
|
|
|
|
|
AudioRecorderStateStopped, // 已停止
|
|
|
|
|
|
AudioRecorderStatePlaying // 试听中
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@class QXAudioRecorderView;
|
|
|
|
|
|
|
|
|
|
|
|
@protocol QXAudioRecorderViewDelegate <NSObject>
|
|
|
|
|
|
|
|
|
|
|
|
@optional
|
|
|
|
|
|
/// 录音状态改变
|
|
|
|
|
|
- (void)qxAudioRecorderView:(QXAudioRecorderView *)recorderView didChangeState:(AudioRecorderState)state;
|
|
|
|
|
|
|
|
|
|
|
|
/// 录音完成
|
|
|
|
|
|
- (void)qxAudioRecorderView:(QXAudioRecorderView *)recorderView didFinishRecordingWithMP3File:(NSURL *)mp3FileURL duration:(NSTimeInterval)duration;
|
|
|
|
|
|
|
|
|
|
|
|
/// 录音失败
|
|
|
|
|
|
- (void)qxAudioRecorderView:(QXAudioRecorderView *)recorderView didFailWithError:(NSError *)error;
|
|
|
|
|
|
|
|
|
|
|
|
/// 录音进度更新
|
|
|
|
|
|
- (void)qxAudioRecorderView:(QXAudioRecorderView *)recorderView didUpdateProgress:(NSTimeInterval)progress totalDuration:(NSTimeInterval)totalDuration;
|
|
|
|
|
|
|
2025-12-04 14:11:00 +08:00
|
|
|
|
/// 开始认证
|
|
|
|
|
|
-(void)didClickAuthWithFileUrl:(NSURL*)audioFileUrl;
|
|
|
|
|
|
|
2025-11-21 16:17:05 +08:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@interface QXAudioRecorderView : UIView
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, weak) id<QXAudioRecorderViewDelegate> delegate;
|
|
|
|
|
|
@property (nonatomic, assign, readonly) AudioRecorderState state;
|
|
|
|
|
|
@property (nonatomic, assign, readonly) NSTimeInterval currentDuration;
|
|
|
|
|
|
@property (nonatomic, assign, readonly) NSTimeInterval totalDuration; // 总录制时长(连续录制)
|
|
|
|
|
|
@property (nonatomic, strong, readonly) NSURL *currentAudioFileURL;
|
|
|
|
|
|
|
|
|
|
|
|
/// 最大录制时长,默认300秒(5分钟)
|
|
|
|
|
|
@property (nonatomic, assign) NSTimeInterval maxDuration;
|
|
|
|
|
|
|
|
|
|
|
|
/// 是否显示试听按钮,默认YES
|
|
|
|
|
|
@property (nonatomic, assign) BOOL showPlaybackButton;
|
|
|
|
|
|
|
|
|
|
|
|
/// 初始化
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame maxDuration:(NSTimeInterval)maxDuration;
|
|
|
|
|
|
|
|
|
|
|
|
/// 开始录制(程序控制)
|
|
|
|
|
|
- (void)startRecording;
|
|
|
|
|
|
|
|
|
|
|
|
/// 停止录制(程序控制)
|
|
|
|
|
|
- (void)stopRecording;
|
|
|
|
|
|
|
|
|
|
|
|
/// 试听录音
|
|
|
|
|
|
- (void)playRecording;
|
|
|
|
|
|
|
|
|
|
|
|
/// 停止试听
|
|
|
|
|
|
- (void)stopPlayback;
|
|
|
|
|
|
|
|
|
|
|
|
/// 重置录音(从0开始)
|
|
|
|
|
|
- (void)resetRecording;
|
|
|
|
|
|
|
|
|
|
|
|
/// 获取当前录制状态信息
|
|
|
|
|
|
- (NSString *)getRecordingStatus;
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|