Git Product home page Git Product logo

recordandplayvoice's Introduction

RecordAndPlayVoice

模仿微信的录音和播放功能,在录音的时候检测音量调整图片,可以实现录音、播放、及删除录音文件功能。

一、使用录音界面

  • cocoapods导入:pod 'LVRecordTool', '~> 1.0' 导入录音和播放功能的文件,具体界面实现可以参考CustomView。

1.将CustomView和Classes两个文件夹的内容添加到项目

2.包含录音界面头文件
#import "LVRecordView.h"

3.在控制器的viewdidload方法中添加以下代码

self.recordView = [LVRecordView recordView];
self.recordView.backgroundColor = [UIColor lightGrayColor];
CGFloat width = [UIScreen mainScreen].bounds.size.width;
self.recordView.frame = CGRectMake(50, 100, width - 2 * 50, 100);
[self.view addSubview:self.recordView];

4.需要需要调整self.recordView的位置即可实现录音功能。

二、用户自己实现了界面

1.将classes文件夹导入到项目中
2.包含录音工具的头文件
#import "LVRecordTool.h"

3.包含一个录音工具对象
/** 录音工具 */

@property (nonatomic, strong) LVRecordTool *recordTool;

4.在初始化方法中实例化录音工具

recordView.recordTool = [LVRecordTool sharedRecordTool];

5.在需要录音的时候添加录音代码

[self.recordTool startRecording];

6.停止录音的代码

[self.recordTool stopRecording];

7.播放录音的代码

[self.recordTool playRecordingFile];

8.销毁录音文件的代码

[self.recordTool destructionRecordingFile];

注意:必须在dealloc方法中添加如下代码,防止内存泄露。

- (void)dealloc {
    [self.recordTool stopPlaying];
    [self.recordTool stopRecording];
}

##录音播放工具效果图

期待

  • 如果在使用过程中遇到BUG,希望你能Issues我,谢谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.