Giter Club home page Giter Club logo

lgaudiokit's Introduction

LGAudioKit

Travis License MIT 

简单易用的语音录制、播放控件。流程和界面参考微信(如果对您有帮助,记得star,动力源自鼓励)

CXLSlideList Screenshot CXLSlideList Screenshot

添加到工程

  • 拷贝'Class'文件夹到你的工程
  • #import "LGAudioKit.h"

播放器 LGAudioPlayer

  • 开始播放
- (void)playAudioWithURLString:(NSString *)URLString atIndex:(NSUInteger)index;

URLString: 语音文件本地路径。如果要播放网络文件,先下载到本地,再播放

  • 停止播放
- (void)stopAudioPlayer
  • 代理方法
- (void)audioPlayerStateDidChanged:(LGAudioPlayerState)audioPlayerState forIndex:(NSUInteger)index
  • 播放状态 LGAudioPlayerState
typedef NS_ENUM(NSUInteger, LGAudioPlayerState){
	LGAudioPlayerStateNormal = 0,/**< 未播放状态 */
	LGAudioPlayerStatePlaying = 2,/**< 正在播放 */
	LGAudioPlayerStateCancel = 3,/**< 播放被取消 */
};

录音器

  • 开始录音
- (void)startSoundRecord:(UIView *)view recordPath:(NSString *)path;

view: 传入录音动画的父view(录音动画要展示的依托view); path: 语音文件存储路径

  • 结束录音
- (void)stopSoundRecord:(UIView *)view;
  • 录音失败/取消录音
- (void)soundRecordFailed:(UIView *)view;
  • 提示‘松开手指,取消录音’。这个状态下,录音继续。
- (void)readyCancelSound;
  • 恢复正常提示动画。(手指重新滑动到按钮范围内,提示‘手指上滑,取消发送’)
- (void)resetNormalRecord;
  • 提示‘说话时间太短’
- (void)showShotTimeSign:(UIView *)view
  • 展示录音倒计时
- (void)showCountdown:(int)countDown;

countDown: 剩余时间,秒。

  • 文件格式转换,caf文件转换为amr
- (NSData *)convertCAFtoAMR:(NSString *)fielPath;
  • 获取录音时长
- (NSTimeInterval)soundRecordTime;

说明

  • Demo中包含两个控件:

    录音控件:'LGSoundRecorder'

    播放控件:'LGSoundPlayer'

  • 录音文件格式为.caf,提供转amr方法,可转成amr发给安卓

  • 播放语音格式支持:amr、caf、wav

  • 具体的使用细节请参考Demo中的ViewController.m

  • 语音录放的一些简单分析请参考 iOS通信软件中的语音录制与播放

环境支持

  • iOS7及以上

lgaudiokit's People

Contributors

gang544043963 avatar makehui avatar

Watchers

James Cloos avatar  avatar

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.