美文网首页
录音与播放

录音与播放

作者: 温暖的弦Y | 来源:发表于2016-07-06 22:53 被阅读30次

介绍:https://github.com/pattyXP

引用头文件 #import"Mp3Recorder.h" 录制音频,需要设置delegate

#import"UUAVAudioPlayer.h" 播放音频



- (void)initData

{

self.mp3Recorder= [[Mp3Recorderalloc]initWithDelegate:self];

}

//开始录音

- (void)click1

{

[self.mp3RecorderstartRecord];

self.playTime=0;

self.playTimer= [NSTimerscheduledTimerWithTimeInterval:1target:selfselector:@selector(countVoiceTime)userInfo:nilrepeats:YES];

}

//开始播放

- (void)click2

{

}

//录音时间

- (void)countVoiceTime

{

self.playTime++;

if(self.playTime>5) {

[selfendRecordVoice];

}

}

//结束录音

- (void)endRecordVoice

{

if(self.playTimer) {

[self.mp3RecorderstopRecord];

[self.playTimerinvalidate];

self.playTimer=nil;

}

}

#pragma mark -录音回调

- (void)endConvertWithData:(NSData*)voiceData

{

self.audioPlayer= [UUAVAudioPlayersharedInstance];

//self.audioPlayer.delegate = self;

[self.audioPlayerplaySongWithData:voiceData];

}

- (void)viewDidLoad {

[superviewDidLoad];

[selfinitData];

//录音

UIButton*btn = [[UIButtonalloc]initWithFrame:CGRectMake(100,100,80,80)];

btn.backgroundColor= [UIColorredColor];

[self.viewaddSubview:btn];

[btnaddTarget:selfaction:@selector(click1)forControlEvents:UIControlEventTouchUpInside];

//播放

UIButton*btn2 = [[UIButtonalloc]initWithFrame:CGRectMake(100,300,80,80)];

btn2.backgroundColor= [UIColorgreenColor];

[self.viewaddSubview:btn2];

[btn2addTarget:selfaction:@selector(click2)forControlEvents:UIControlEventTouchUpInside];

// Do any additional setup after loading the view, typically from a nib.

}

相关文章

  • 录音与播放录音

    按下录音的点击事件 抬手结束录音触发事件 播发按钮的点击事件

  • iOS 录音-上传与播放解析

    title : iOS 录音-上传与播放解析category : IOS iOS 录音-上传与播放解析 标签(...

  • 录音与播放

    介绍:https://github.com/pattyXP 引用头文件 #import"Mp3Recorder.h...

  • android 日常 (十六)

    录音实现之AudioRecord类手机录音与播放 【Android】【录音】Android录音--AudioRec...

  • 安卓实现录音的开始/播放/暂停/继续的功能

    目录:1、开始录音2、结束录音3、播放录音4、暂停/继续 1、开始录音 2、结束录音 3、播放录音播放录音资源使用...

  • AudioQueue 录音与播放

    主要部分: 播放pcm文件流 实时录音和播放 AudioQueue播放pcm文件流 导入头文件定义所需变量 读pc...

  • iOS 录音与播放

    实现思路 利用系统框架AVFoundation实现录音和录音播放 注意事项 在Info.plist文件中添加如下代...

  • Android 录音与播放

    网上查了下,Android 用 MediaRecorder 和 AudioRecord 实现录音。这里主要是用 M...

  • 小程序 录音 播放实现

    录音需要现在js文件定义录音和播放对象 录音开始方法 录音结束方法 播放录音方法:

  • 录音播放

    效果如图 主要代码如下 #import "ViewController.h"#import#import "lam...

网友评论

      本文标题:录音与播放

      本文链接:https://www.haomeiwen.com/subject/hwlnrttx.html