add .gitignore
26
msext/Class/record/ChatRecorderView.h
Executable file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// ChatRecorderView.h
|
||||
// Jeans
|
||||
//
|
||||
// Created by Jeans on 3/24/13.
|
||||
// Copyright (c) 2013 Jeans. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
|
||||
@interface ChatRecorderView : UIView
|
||||
|
||||
@property (retain, nonatomic) IBOutlet UIImageView *peakMeterIV;
|
||||
|
||||
@property (retain, nonatomic) IBOutlet UIView *background;
|
||||
@property (retain, nonatomic) IBOutlet UILabel *countDownLabel;
|
||||
|
||||
//还原界面
|
||||
- (void)restoreDisplay;
|
||||
|
||||
//更新音频峰值
|
||||
- (void)updateMetersByAvgPower:(float)_avgPower;
|
||||
|
||||
@end
|
||||
114
msext/Class/record/ChatRecorderView.m
Executable file
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// ChatRecorderView.m
|
||||
// Jeans
|
||||
//
|
||||
// Created by Jeans on 3/24/13.
|
||||
// Copyright (c) 2013 Jeans. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ChatRecorderView.h"
|
||||
|
||||
@interface ChatRecorderView(){
|
||||
NSArray *peakImageAry;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation ChatRecorderView
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initilization];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(NSCoder *)aDecoder{
|
||||
self = [super initWithCoder:aDecoder];
|
||||
if (self) {
|
||||
[self initilization];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)initilization{
|
||||
//初始化音量peak峰值图片数组
|
||||
|
||||
peakImageAry = [[NSArray alloc]initWithObjects:
|
||||
[UIImage imageNamed:@"record_animate_01.png"],
|
||||
[UIImage imageNamed:@"record_animate_02.png"],
|
||||
[UIImage imageNamed:@"record_animate_03.png"],
|
||||
[UIImage imageNamed:@"record_animate_04.png"],
|
||||
[UIImage imageNamed:@"record_animate_05.png"],
|
||||
[UIImage imageNamed:@"record_animate_06.png"],
|
||||
[UIImage imageNamed:@"record_animate_07.png"],
|
||||
[UIImage imageNamed:@"record_animate_08.png"],
|
||||
[UIImage imageNamed:@"record_animate_09.png"],
|
||||
[UIImage imageNamed:@"record_animate_10.png"],
|
||||
[UIImage imageNamed:@"record_animate_11.png"],
|
||||
[UIImage imageNamed:@"record_animate_12.png"],
|
||||
[UIImage imageNamed:@"record_animate_13.png"],
|
||||
[UIImage imageNamed:@"record_animate_14.png"],
|
||||
nil];
|
||||
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[peakImageAry release];
|
||||
[_peakMeterIV release];
|
||||
[_countDownLabel release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
#pragma mark -还原显示界面
|
||||
- (void)restoreDisplay{
|
||||
//还原录音图
|
||||
self.background.layer.masksToBounds = YES;
|
||||
self.background.layer.cornerRadius = 8;
|
||||
|
||||
_peakMeterIV.image = [peakImageAry objectAtIndex:0];
|
||||
|
||||
//还原倒计时文本
|
||||
_countDownLabel.text = @"";
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark - 更新音频峰值
|
||||
- (void)updateMetersByAvgPower:(float)_avgPower{
|
||||
//-160表示完全安静,0表示最大输入值
|
||||
//
|
||||
NSInteger imageIndex = 0;
|
||||
if (_avgPower >= -56 && _avgPower < -52)
|
||||
imageIndex = 1;
|
||||
else if (_avgPower >= -52 && _avgPower < -48)
|
||||
imageIndex = 2;
|
||||
else if (_avgPower >= -48 && _avgPower < -44)
|
||||
imageIndex = 3;
|
||||
else if (_avgPower >= -44 && _avgPower < -40)
|
||||
imageIndex = 4;
|
||||
else if (_avgPower >= -40 && _avgPower < -36)
|
||||
imageIndex = 5;
|
||||
else if (_avgPower >= -36 && _avgPower < -34)
|
||||
imageIndex = 6;
|
||||
else if (_avgPower >= -34 && _avgPower < -30)
|
||||
imageIndex = 7;
|
||||
else if (_avgPower >= -30 && _avgPower < -26)
|
||||
imageIndex = 8;
|
||||
else if (_avgPower >= -26 && _avgPower < -22)
|
||||
imageIndex = 9;
|
||||
else if (_avgPower >= -22 && _avgPower < -18)
|
||||
imageIndex = 10;
|
||||
else if (_avgPower >= -18 && _avgPower < -14)
|
||||
imageIndex = 11;
|
||||
else if (_avgPower >= -14 && _avgPower < -10)
|
||||
imageIndex = 12;
|
||||
else if (_avgPower >= -10)
|
||||
imageIndex = 13;
|
||||
|
||||
_peakMeterIV.image = [peakImageAry objectAtIndex:imageIndex];
|
||||
}
|
||||
|
||||
@end
|
||||
63
msext/Class/record/ChatRecorderView.xib
Executable file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11542" systemVersion="15G1108" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view contentMode="scaleToFill" id="2" customClass="ChatRecorderView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="125" height="130"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<view alpha="0.34999999403953552" contentMode="scaleToFill" id="10">
|
||||
<rect key="frame" x="0.0" y="0.0" width="125" height="130"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="7">
|
||||
<rect key="frame" x="24" y="46" width="145" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="手指拿开,取消发送" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="11">
|
||||
<rect key="frame" x="11" y="105" width="102" height="15"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="tableCellGroupedBackgroundColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
</view>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="record_animate_01.png" id="3">
|
||||
<rect key="frame" x="32" y="11" width="60" height="88"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="simulatedStatusBarMetrics"/>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<connections>
|
||||
<outlet property="background" destination="10" id="12"/>
|
||||
<outlet property="countDownLabel" destination="7" id="8"/>
|
||||
<outlet property="peakMeterIV" destination="3" id="5"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="192.5" y="271"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="record_animate_01.png" width="75" height="111"/>
|
||||
</resources>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
|
||||
</simulatedMetricsContainer>
|
||||
</document>
|
||||
21
msext/Class/record/ChatVoiceRecorderVC.h
Executable file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// ChatVoiceRecorderVC.h
|
||||
// Jeans
|
||||
//
|
||||
// Created by Jeans on 3/23/13.
|
||||
// Copyright (c) 2013 Jeans. All rights reserved.
|
||||
//
|
||||
|
||||
#import "VoiceRecorderBaseVC.h"
|
||||
|
||||
|
||||
#define kRecorderViewRect CGRectMake(([[UIScreen mainScreen]bounds].size.width-125)/2, 98, 125, 130)
|
||||
//#define kCancelOriginY (kRecorderViewRect.origin.y + kRecorderViewRect.size.height + 180)
|
||||
#define kCancelOriginY ([[UIScreen mainScreen]bounds].size.width-70)
|
||||
|
||||
@interface ChatVoiceRecorderVC : VoiceRecorderBaseVC
|
||||
|
||||
//开始录音
|
||||
- (void)beginRecordByFileName:(NSString*)_fileName;
|
||||
|
||||
@end
|
||||
288
msext/Class/record/ChatVoiceRecorderVC.m
Executable file
@@ -0,0 +1,288 @@
|
||||
//
|
||||
// ChatVoiceRecorderVC.m
|
||||
// Jeans
|
||||
//
|
||||
// Created by Jeans on 3/23/13.
|
||||
// Copyright (c) 2013 Jeans. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ChatVoiceRecorderVC.h"
|
||||
#import "UIView+Animation.h"
|
||||
#import "ChatRecorderView.h"
|
||||
|
||||
@interface ChatVoiceRecorderVC ()<AVAudioRecorderDelegate>{
|
||||
CGFloat curCount; //当前计数,初始为0
|
||||
ChatRecorderView *recorderView; //录音界面
|
||||
CGPoint curTouchPoint; //触摸点
|
||||
BOOL canNotSend; //不能发送
|
||||
NSTimer *timer;
|
||||
}
|
||||
|
||||
@property (retain, nonatomic) AVAudioRecorder *recorder;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ChatVoiceRecorderVC
|
||||
@synthesize recorder;
|
||||
|
||||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
||||
{
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if (self) {
|
||||
// Custom initialization
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view from its nib.
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
- (void)dealloc{
|
||||
[recorder release];
|
||||
[recorderView release];
|
||||
[super dealloc];
|
||||
}
|
||||
- (BOOL)canRecord
|
||||
{
|
||||
__block BOOL bCanRecord = YES;
|
||||
if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending)
|
||||
{
|
||||
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
|
||||
if ([audioSession respondsToSelector:@selector(requestRecordPermission:)]) {
|
||||
[audioSession performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {
|
||||
if (granted) {
|
||||
bCanRecord = YES;
|
||||
} else {
|
||||
bCanRecord = NO;
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
return bCanRecord;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//-(int)ifauth
|
||||
//{
|
||||
// int flag;
|
||||
// AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
|
||||
// switch (authStatus) {
|
||||
// case AVAuthorizationStatusNotDetermined:
|
||||
// //没有询问是否开启麦克风
|
||||
// flag = 1;
|
||||
// break;
|
||||
// case AVAuthorizationStatusRestricted:
|
||||
// //未授权,家长限制
|
||||
// flag = 0;
|
||||
// break;
|
||||
// case AVAuthorizationStatusDenied:
|
||||
// //玩家未授权
|
||||
// flag = 0;
|
||||
// break;
|
||||
// case AVAuthorizationStatusAuthorized:
|
||||
// //玩家授权
|
||||
// flag = 2;
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// return flag;
|
||||
//}
|
||||
|
||||
#pragma mark - 开始录音
|
||||
- (void)beginRecordByFileName:(NSString*)_fileName;{
|
||||
|
||||
|
||||
//设置文件名和录音路径
|
||||
self.recordFileName = _fileName;
|
||||
self.recordFilePath = [VoiceRecorderBaseVC getPathByFileName:recordFileName ofType:@"wav"];
|
||||
|
||||
//初始化录音
|
||||
self.recorder = [[[AVAudioRecorder alloc]initWithURL:[NSURL URLWithString:recordFilePath]
|
||||
settings:[VoiceRecorderBaseVC getAudioRecorderSettingDict]
|
||||
error:nil]autorelease];
|
||||
recorder.delegate = self;
|
||||
recorder.meteringEnabled = YES;
|
||||
|
||||
[recorder prepareToRecord];
|
||||
|
||||
//还原计数
|
||||
curCount = 0;
|
||||
//还原发送
|
||||
canNotSend = NO;
|
||||
|
||||
//开始录音
|
||||
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error:nil];
|
||||
[[AVAudioSession sharedInstance] setActive:YES error:nil];
|
||||
|
||||
|
||||
[recorder record];
|
||||
|
||||
//启动计时器
|
||||
[self startTimer];
|
||||
|
||||
//显示录音界面
|
||||
[self initRecordView];
|
||||
[UIView showView:recorderView
|
||||
animateType:AnimateTypeOfPopping
|
||||
finalRect:kRecorderViewRect
|
||||
completion:^(BOOL finish){
|
||||
if (finish){
|
||||
//注册nScreenTouch事件
|
||||
[self addScreenTouchObserver];
|
||||
}
|
||||
}];
|
||||
//设置遮罩背景不可触摸
|
||||
[UIView setTopMaskViewCanTouch:NO];
|
||||
}
|
||||
#pragma mark - 初始化录音界面
|
||||
- (void)initRecordView{
|
||||
if (recorderView == nil)
|
||||
recorderView = (ChatRecorderView*)[[[[NSBundle mainBundle]loadNibNamed:@"ChatRecorderView" owner:self options:nil]lastObject]retain];
|
||||
//还原界面显示
|
||||
[recorderView restoreDisplay];
|
||||
}
|
||||
#pragma mark - 启动定时器
|
||||
- (void)startTimer{
|
||||
timer = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(updateMeters) userInfo:nil repeats:YES];
|
||||
}
|
||||
|
||||
#pragma mark - 停止定时器
|
||||
- (void)stopTimer{
|
||||
if (timer && timer.isValid){
|
||||
[timer invalidate];
|
||||
timer = nil;
|
||||
}
|
||||
}
|
||||
#pragma mark - 更新音频峰值
|
||||
- (void)updateMeters{
|
||||
if (recorder.isRecording){
|
||||
|
||||
//更新峰值
|
||||
[recorder updateMeters];
|
||||
[recorderView updateMetersByAvgPower:[recorder averagePowerForChannel:0]];
|
||||
// NSLog(@"峰值:%f",[recorder averagePowerForChannel:0]);
|
||||
|
||||
//倒计时
|
||||
if (curCount >= maxRecordTime - 10 && curCount < maxRecordTime) {
|
||||
//剩下10秒
|
||||
recorderView.countDownLabel.text = [NSString stringWithFormat:@"录音剩下:%d秒",(int)(maxRecordTime-curCount)];
|
||||
}else if (curCount >= maxRecordTime){
|
||||
//时间到
|
||||
[self touchEnded:curTouchPoint];
|
||||
}
|
||||
curCount += 0.1f;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 移除触摸观察者
|
||||
- (void)removeScreenTouchObserver{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"nScreenTouch" object:nil];//移除nScreenTouch事件
|
||||
}
|
||||
#pragma mark - 添加触摸观察者
|
||||
- (void)addScreenTouchObserver{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onScreenTouch:) name:@"nScreenTouch" object:nil];
|
||||
}
|
||||
-(void)onScreenTouch:(NSNotification *)notification {
|
||||
UIEvent *event=[notification.userInfo objectForKey:@"data"];
|
||||
NSSet *allTouches = event.allTouches;
|
||||
|
||||
//如果未触摸或只有单点触摸
|
||||
if ((curTouchPoint.x == CGPointZero.x && curTouchPoint.y == CGPointZero.y) || allTouches.count == 1)
|
||||
[self transferTouch:[allTouches anyObject]];
|
||||
else{
|
||||
//遍历touch,找到最先触摸的那个touch
|
||||
for (UITouch *touch in allTouches){
|
||||
CGPoint prePoint = [touch previousLocationInView:nil];
|
||||
|
||||
if (prePoint.x == curTouchPoint.x && prePoint.y == curTouchPoint.y)
|
||||
[self transferTouch:touch];
|
||||
}
|
||||
}
|
||||
}
|
||||
//传递触点
|
||||
- (void)transferTouch:(UITouch*)_touch{
|
||||
CGPoint point = [_touch locationInView:nil];
|
||||
switch (_touch.phase) {
|
||||
case UITouchPhaseBegan:
|
||||
[self touchBegan:point];
|
||||
break;
|
||||
case UITouchPhaseMoved:
|
||||
[self touchMoved:point];
|
||||
break;
|
||||
case UITouchPhaseCancelled:
|
||||
case UITouchPhaseEnded:
|
||||
[self touchEnded:point];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#pragma mark - 触摸开始
|
||||
- (void)touchBegan:(CGPoint)_point{
|
||||
curTouchPoint = _point;
|
||||
}
|
||||
#pragma mark - 触摸移动
|
||||
- (void)touchMoved:(CGPoint)_point{
|
||||
curTouchPoint = _point;
|
||||
//判断是否移动到取消区域
|
||||
// canNotSend = _point.y < kCancelOriginY ? YES : NO;
|
||||
|
||||
canNotSend=NO;
|
||||
}
|
||||
#pragma mark - 触摸结束
|
||||
- (void)touchEnded:(CGPoint)_point{
|
||||
//停止计时器
|
||||
[self stopTimer];
|
||||
|
||||
curTouchPoint = CGPointZero;
|
||||
[self removeScreenTouchObserver];
|
||||
|
||||
[UIView hideViewByCompletion:^(BOOL finish){
|
||||
|
||||
//停止录音
|
||||
if (recorder.isRecording)
|
||||
[recorder stop];
|
||||
|
||||
if (canNotSend) {
|
||||
//取消发送,删除文件
|
||||
[VoiceRecorderBaseVC deleteFileAtPath:recordFilePath];
|
||||
}else{
|
||||
//回调录音文件路径
|
||||
if ([self.vrbDelegate respondsToSelector:@selector(VoiceRecorderBaseVCRecordFinish:fileName:)])
|
||||
[self.vrbDelegate VoiceRecorderBaseVCRecordFinish:recordFilePath fileName:recordFileName];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - AVAudioRecorder Delegate Methods
|
||||
- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag{
|
||||
NSLog(@"录音停止");
|
||||
|
||||
[self stopTimer];
|
||||
curCount = 0;
|
||||
}
|
||||
- (void)audioRecorderBeginInterruption:(AVAudioRecorder *)recorder{
|
||||
NSLog(@"录音开始");
|
||||
[self stopTimer];
|
||||
curCount = 0;
|
||||
}
|
||||
- (void)audioRecorderEndInterruption:(AVAudioRecorder *)recorder withOptions:(NSUInteger)flags{
|
||||
NSLog(@"录音中断");
|
||||
[self stopTimer];
|
||||
curCount = 0;
|
||||
}
|
||||
|
||||
@end
|
||||
127
msext/Class/record/ChatVoiceRecorderVC.xib
Executable file
@@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1296</int>
|
||||
<string key="IBDocument.SystemVersion">14C1514</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">6751</string>
|
||||
<string key="IBDocument.AppKitVersion">1344.72</string>
|
||||
<string key="IBDocument.HIToolboxVersion">757.30</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="NS.object.0">6736</string>
|
||||
</object>
|
||||
<array key="IBDocument.IntegratedClassDependencies">
|
||||
<string>IBProxyObject</string>
|
||||
<string>IBUIView</string>
|
||||
</array>
|
||||
<array key="IBDocument.PluginDependencies">
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</array>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
|
||||
<integer value="1" key="NS.object.0"/>
|
||||
</object>
|
||||
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
|
||||
<object class="IBProxyObject" id="372490531">
|
||||
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBProxyObject" id="975951072">
|
||||
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBUIView" id="191373211">
|
||||
<nil key="NSNextResponder"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
<object class="NSColorSpace" key="NSCustomColorSpace">
|
||||
<int key="NSID">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
|
||||
<object class="IBUIScreenMetrics" key="IBUISimulatedDestinationMetrics">
|
||||
<string key="IBUISimulatedSizeMetricsClass">IBUIScreenMetrics</string>
|
||||
<string key="IBUITargetRuntime">IBCocoaTouchFramework</string>
|
||||
<string key="IBUIDisplayName">iPhone 3.5-inch</string>
|
||||
<object class="NSMutableDictionary" key="IBUINormalizedOrientationToSizeMap">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<array key="dict.sortedKeys">
|
||||
<integer value="1"/>
|
||||
<integer value="3"/>
|
||||
</array>
|
||||
<array key="dict.values">
|
||||
<string>{320, 480}</string>
|
||||
<string>{480, 320}</string>
|
||||
</array>
|
||||
</object>
|
||||
<int key="IBUIType">0</int>
|
||||
</object>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<array key="connectionRecords">
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">view</string>
|
||||
<reference key="source" ref="372490531"/>
|
||||
<reference key="destination" ref="191373211"/>
|
||||
</object>
|
||||
<int key="connectionID">3</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<array key="object" id="0"/>
|
||||
<reference key="children" ref="1000"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">1</int>
|
||||
<reference key="object" ref="191373211"/>
|
||||
<array class="NSMutableArray" key="children"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-1</int>
|
||||
<reference key="object" ref="372490531"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">File's Owner</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="975951072"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
<string key="-1.CustomClassName">ChatVoiceRecorderVC</string>
|
||||
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="-2.CustomClassName">UIResponder</string>
|
||||
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">4</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes"/>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<bool key="IBDocument.previouslyAttemptedUpgradeToXcode5">NO</bool>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
|
||||
<integer value="4600" key="NS.object.0"/>
|
||||
</object>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
</data>
|
||||
</archive>
|
||||
13
msext/Class/record/CustomWindow.h
Executable file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// CustomWindow.h
|
||||
// AmrConvertAndRecord
|
||||
//
|
||||
// Created by Jeans on 3/29/13.
|
||||
// Copyright (c) 2013 Jeans. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface CustomWindow : UIWindow
|
||||
|
||||
@end
|
||||
37
msext/Class/record/CustomWindow.m
Executable file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// CustomWindow.m
|
||||
// AmrConvertAndRecord
|
||||
//
|
||||
// Created by Jeans on 3/29/13.
|
||||
// Copyright (c) 2013 Jeans. All rights reserved.
|
||||
//
|
||||
|
||||
#import "CustomWindow.h"
|
||||
|
||||
@implementation CustomWindow
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
// Initialization code
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)sendEvent:(UIEvent *)event {
|
||||
@try {
|
||||
|
||||
if (event.type == UIEventTypeTouches) {//发送一个名为‘nScreenTouch’(自定义)的事件
|
||||
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"nScreenTouch" object:nil userInfo:[NSDictionary dictionaryWithObject:event forKey:@"data"]]];
|
||||
}
|
||||
[super sendEvent:event];
|
||||
} @catch (NSException *exception) {
|
||||
NSLog(@"%@",exception);
|
||||
} @finally {
|
||||
NSLog(@"@finally");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
56
msext/Class/record/UIViewAnimation/UIView+Animation.h
Executable file
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// UIView+Animation.h
|
||||
//
|
||||
//
|
||||
// Created by Jeans on 3/9/13.
|
||||
// Copyright (c) 2013 Jeans. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#define kDefaultAnimateTime 0.25f
|
||||
|
||||
typedef enum AnimateType{ //动画类型
|
||||
AnimateTypeOfTV, //电视
|
||||
AnimateTypeOfPopping, //弹性缩小放大
|
||||
AnimateTypeOfLeft, //左
|
||||
AnimateTypeOfRight, //右
|
||||
AnimateTypeOfTop, //上
|
||||
AnimateTypeOfBottom //下
|
||||
}AnimateType;
|
||||
|
||||
@interface UIView (Animation)
|
||||
|
||||
#pragma mark - 获取顶部View
|
||||
+ (UIView *)getTopView;
|
||||
|
||||
#pragma mark - 顶层maskView触摸
|
||||
+ (void)setTopMaskViewCanTouch:(BOOL)_canTouch;
|
||||
|
||||
/**
|
||||
显示view
|
||||
@param _view 需要显示的view
|
||||
@param _aType 动画类型
|
||||
@param _fRect 最终位置
|
||||
*/
|
||||
+ (void)showView:(UIView*)_view animateType:(AnimateType)_aType finalRect:(CGRect)_fRect;
|
||||
|
||||
|
||||
/**
|
||||
消失view
|
||||
*/
|
||||
+ (void)hideView;
|
||||
|
||||
|
||||
/**
|
||||
消失view
|
||||
@param _aType 动画类型
|
||||
*/
|
||||
+ (void)hideViewByType:(AnimateType)_aType;
|
||||
|
||||
|
||||
#pragma mark - 下面的增加了完成块
|
||||
+ (void)showView:(UIView*)_view animateType:(AnimateType)_aType finalRect:(CGRect)_fRect completion:(void(^)(BOOL finished))completion;
|
||||
+ (void)hideViewByCompletion:(void(^)(BOOL finished))completion;
|
||||
+ (void)hideViewByType:(AnimateType)_aType completion:(void(^)(BOOL finished))completion;
|
||||
@end
|
||||
286
msext/Class/record/UIViewAnimation/UIView+Animation.m
Executable file
@@ -0,0 +1,286 @@
|
||||
//
|
||||
// UIView+Animation.m
|
||||
//
|
||||
//
|
||||
// Created by Jeans on 3/9/13.
|
||||
// Copyright (c) 2013 Jeans. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UIView+Animation.h"
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#define kScaleMin 0.007f
|
||||
#define kScaleDefault 1.0f
|
||||
#define kScaleDelta 0.05f
|
||||
|
||||
|
||||
#define kFirstAnimateTime 0.3f
|
||||
#define kSecondAnimateTime 0.2f
|
||||
|
||||
#define kMaskViewFinalAlpha 0.2f //背景的透明度
|
||||
|
||||
@interface ViewInfo : NSObject{
|
||||
AnimateType aType; //动画类型
|
||||
UIView *displayView; //显示页面
|
||||
CGRect displayRect; //显示的位置
|
||||
UIControl *maskView; //遮挡页面
|
||||
void (^showBlock)(BOOL finished);
|
||||
void (^hideBlock)(BOOL finished);
|
||||
}
|
||||
|
||||
@property (retain, nonatomic) UIView *displayView;
|
||||
@property (assign, nonatomic) AnimateType aType;
|
||||
@property (assign, nonatomic) CGRect displayRect;
|
||||
@property (retain, nonatomic) UIControl *maskView;
|
||||
@property (copy, nonatomic) void (^showBlock)(BOOL finished);
|
||||
@property (copy, nonatomic) void (^hideBlock)(BOOL finished);
|
||||
@end
|
||||
|
||||
@implementation ViewInfo
|
||||
|
||||
@synthesize displayView,aType,maskView,displayRect,showBlock,hideBlock;
|
||||
- (void)dealloc{
|
||||
Block_release(hideBlock);
|
||||
Block_release(showBlock);
|
||||
[maskView release];
|
||||
[displayView release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIView (Animation)
|
||||
|
||||
static NSMutableArray *displayViewAry;//已显示的页面数组
|
||||
|
||||
#pragma mark - 获取顶部View
|
||||
+ (AppDelegate *)getAppDelegate {
|
||||
return (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
||||
}
|
||||
+ (UIView *)getTopView{
|
||||
return [[UIApplication sharedApplication].windows objectAtIndex:0];
|
||||
// return [FuncPublic SharedFuncPublic].currentVC.view;
|
||||
return [[[UIView getAppDelegate] root] view];
|
||||
}
|
||||
|
||||
#pragma mark - 顶层maskView触摸
|
||||
+ (void)setTopMaskViewCanTouch:(BOOL)_canTouch{
|
||||
ViewInfo *info = [displayViewAry lastObject];
|
||||
if (_canTouch)
|
||||
[info.maskView addTarget:self action:@selector(maskViewTouch) forControlEvents:UIControlEventTouchUpInside];
|
||||
else
|
||||
[info.maskView removeTarget:self action:@selector(maskViewTouch) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - 下面的增加了完成块
|
||||
/**
|
||||
显示view
|
||||
@param _view 需要显示的view
|
||||
@param _aType 动画类型
|
||||
@param _fRect 最终位置
|
||||
@param completion 动画块
|
||||
*/
|
||||
+ (void)showView:(UIView*)_view animateType:(AnimateType)_aType finalRect:(CGRect)_fRect completion:(void(^)(BOOL finished))completion{
|
||||
//初始化页面数组
|
||||
if (displayViewAry == nil)
|
||||
displayViewAry = [[NSMutableArray alloc]init];
|
||||
|
||||
UIView *topView = [UIView getTopView];
|
||||
|
||||
//存储页面信息
|
||||
ViewInfo *info = [[ViewInfo alloc]init];
|
||||
info.displayView = _view;
|
||||
info.aType = _aType;
|
||||
info.displayRect = _fRect;
|
||||
|
||||
//初始化遮罩页面
|
||||
UIControl *maskView = [[UIControl alloc]init];
|
||||
maskView.backgroundColor = [UIColor blackColor];
|
||||
maskView.alpha = 0;
|
||||
maskView.frame = topView.bounds;
|
||||
[maskView addTarget:self action:@selector(maskViewTouch) forControlEvents:UIControlEventTouchUpInside];
|
||||
//添加页面
|
||||
[topView addSubview:maskView];
|
||||
[topView bringSubviewToFront:maskView];
|
||||
|
||||
info.maskView = maskView;
|
||||
[maskView release];
|
||||
|
||||
if (completion)
|
||||
info.showBlock = completion;
|
||||
|
||||
[displayViewAry addObject:info];
|
||||
[info release];
|
||||
|
||||
|
||||
//根据不同的动画类型显示
|
||||
switch (_aType) {
|
||||
case AnimateTypeOfTV:
|
||||
[UIView showTV];
|
||||
break;
|
||||
case AnimateTypeOfPopping:
|
||||
[UIView showPopping];
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
显示view
|
||||
@param _view 需要显示的view
|
||||
@param _aType 动画类型
|
||||
@param _fRect 最终位置
|
||||
*/
|
||||
+ (void)showView:(UIView*)_view animateType:(AnimateType)_aType finalRect:(CGRect)_fRect{
|
||||
[self showView:_view animateType:_aType finalRect:_fRect completion:nil];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - 消失view
|
||||
|
||||
+ (void)hideViewByCompletion:(void(^)(BOOL finished))completion{
|
||||
if ([displayViewAry count] > 0){
|
||||
ViewInfo *info = [displayViewAry lastObject];
|
||||
if (completion)
|
||||
info.hideBlock = completion;
|
||||
}
|
||||
[UIView maskViewTouch];
|
||||
}
|
||||
+ (void)hideViewByType:(AnimateType)_aType completion:(void(^)(BOOL finished))completion{
|
||||
if ([displayViewAry count] > 0){
|
||||
ViewInfo *info = [displayViewAry lastObject];
|
||||
info.aType = _aType;
|
||||
if (completion)
|
||||
info.hideBlock = completion;
|
||||
}
|
||||
[UIView maskViewTouch];
|
||||
}
|
||||
//
|
||||
+ (void)hideView{
|
||||
[UIView hideViewByCompletion:nil];
|
||||
}
|
||||
+ (void)hideViewByType:(AnimateType)_aType{
|
||||
[UIView hideViewByType:_aType completion:nil];
|
||||
}
|
||||
|
||||
#pragma mark - 触摸背景
|
||||
+ (void)maskViewTouch{
|
||||
if ([displayViewAry count] > 0){
|
||||
ViewInfo *info = [displayViewAry lastObject];
|
||||
|
||||
//根据不同类型隐藏
|
||||
switch (info.aType) {
|
||||
case AnimateTypeOfTV:
|
||||
[UIView hideTV];
|
||||
break;
|
||||
case AnimateTypeOfPopping:
|
||||
[UIView hidePopping];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma mark - 移除遮罩和已显示页面
|
||||
+ (void)removeMaskViewAndDisplay:(ViewInfo*)info{
|
||||
if (info.aType == AnimateTypeOfTV || info.aType == AnimateTypeOfPopping) //TV,Popping 类型需要还原
|
||||
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault, kScaleDefault);
|
||||
|
||||
[info.displayView removeFromSuperview];
|
||||
[info.maskView removeFromSuperview];
|
||||
[displayViewAry removeObject:info];
|
||||
}
|
||||
|
||||
#pragma mark - 显示动画
|
||||
|
||||
#pragma mark - TV 显示
|
||||
+ (void)showTV{
|
||||
ViewInfo *info = [displayViewAry lastObject];
|
||||
UIView *topView = [UIView getTopView];
|
||||
info.displayView.frame = info.displayRect;
|
||||
[topView addSubview:info.displayView];
|
||||
[topView bringSubviewToFront:info.displayView];
|
||||
|
||||
info.displayView.transform = CGAffineTransformMakeScale(kScaleMin, kScaleMin);
|
||||
|
||||
//开始动画
|
||||
[UIView animateWithDuration:kSecondAnimateTime animations:^{
|
||||
info.maskView.alpha = 0.1f;
|
||||
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault, kScaleMin);
|
||||
}completion:^(BOOL finish){
|
||||
[UIView animateWithDuration:kFirstAnimateTime animations:^{
|
||||
info.maskView.alpha = kMaskViewFinalAlpha;
|
||||
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault, kScaleDefault);
|
||||
}completion:^(BOOL finish){
|
||||
//调用完成动画块
|
||||
if (info.showBlock)
|
||||
info.showBlock(finish);
|
||||
}];
|
||||
}];
|
||||
}
|
||||
#pragma mark - TV 消失
|
||||
+ (void)hideTV{
|
||||
|
||||
ViewInfo *info = [displayViewAry lastObject];
|
||||
|
||||
[UIView animateWithDuration:kSecondAnimateTime animations:^{
|
||||
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault, kScaleMin);
|
||||
}completion:^(BOOL finish){
|
||||
[UIView animateWithDuration:kFirstAnimateTime animations:^{
|
||||
info.displayView.transform = CGAffineTransformMakeScale(kScaleMin, kScaleMin);
|
||||
info.maskView.alpha = 0;
|
||||
}completion:^(BOOL finish){
|
||||
//调用完成动画块
|
||||
if (info.hideBlock)
|
||||
info.hideBlock(finish);
|
||||
[UIView removeMaskViewAndDisplay:info];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Popping 显示
|
||||
+ (void)showPopping{
|
||||
ViewInfo *info = [displayViewAry lastObject];
|
||||
UIView *topView = [UIView getTopView];
|
||||
info.displayView.frame = info.displayRect;
|
||||
[topView addSubview:info.displayView];
|
||||
[topView bringSubviewToFront:info.displayView];
|
||||
|
||||
info.displayView.transform = CGAffineTransformMakeScale(kScaleMin, kScaleMin);
|
||||
|
||||
//开始动画
|
||||
[UIView animateWithDuration:kFirstAnimateTime animations:^{
|
||||
info.maskView.alpha = kMaskViewFinalAlpha;
|
||||
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault+kScaleDelta, kScaleDefault+kScaleDelta);
|
||||
}completion:^(BOOL finish){
|
||||
[UIView animateWithDuration:kSecondAnimateTime animations:^{
|
||||
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault-kScaleDelta, kScaleDefault-kScaleDelta);
|
||||
}completion:^(BOOL finish){
|
||||
[UIView animateWithDuration:kSecondAnimateTime animations:^{
|
||||
info.displayView.transform = CGAffineTransformMakeScale(kScaleDefault, kScaleDefault);
|
||||
}completion:^(BOOL finish){
|
||||
//调用完成动画块
|
||||
if (info.showBlock)
|
||||
info.showBlock(finish);
|
||||
}];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
#pragma mark - Popping 消失
|
||||
+ (void)hidePopping{
|
||||
ViewInfo *info = [displayViewAry lastObject];
|
||||
|
||||
[UIView animateWithDuration:kFirstAnimateTime animations:^{
|
||||
info.maskView.alpha = 0;
|
||||
info.displayView.transform = CGAffineTransformMakeScale(kScaleMin, kScaleMin);
|
||||
}completion:^(BOOL finish){
|
||||
//调用完成动画块
|
||||
if (info.hideBlock)
|
||||
info.hideBlock(finish);
|
||||
[UIView removeMaskViewAndDisplay:info];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
81
msext/Class/record/VoiceRecorderBaseVC.h
Executable file
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// VoiceRecorderBaseVC.h
|
||||
// Jeans
|
||||
//
|
||||
// Created by Jeans on 3/23/13.
|
||||
// Copyright (c) 2013 Jeans. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "AudioToolbox/AudioToolbox.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <CoreAudio/CoreAudioTypes.h>
|
||||
|
||||
//默认最大录音时间
|
||||
#define kDefaultMaxRecordTime 60
|
||||
|
||||
@protocol VoiceRecorderBaseVCDelegate <NSObject>
|
||||
|
||||
//录音完成回调,返回文件路径和文件名
|
||||
- (void)VoiceRecorderBaseVCRecordFinish:(NSString *)_filePath fileName:(NSString*)_fileName;
|
||||
|
||||
@end
|
||||
|
||||
@interface VoiceRecorderBaseVC : UIViewController{
|
||||
|
||||
@protected
|
||||
NSInteger maxRecordTime; //最大录音时间
|
||||
NSString *recordFileName;//录音文件名
|
||||
NSString *recordFilePath;//录音文件路径
|
||||
}
|
||||
|
||||
@property (assign, nonatomic) id<VoiceRecorderBaseVCDelegate> vrbDelegate;
|
||||
|
||||
@property (assign, nonatomic) NSInteger maxRecordTime;//最大录音时间
|
||||
@property (copy, nonatomic) NSString *recordFileName;//录音文件名
|
||||
@property (copy, nonatomic) NSString *recordFilePath;//录音文件路径
|
||||
|
||||
/**
|
||||
生成当前时间字符串
|
||||
@returns 当前时间字符串
|
||||
*/
|
||||
+ (NSString*)getCurrentTimeString;
|
||||
|
||||
/**
|
||||
获取缓存路径
|
||||
@returns 缓存路径
|
||||
*/
|
||||
+ (NSString*)getCacheDirectory;
|
||||
|
||||
/**
|
||||
判断文件是否存在
|
||||
@param _path 文件路径
|
||||
@returns 存在返回yes
|
||||
*/
|
||||
+ (BOOL)fileExistsAtPath:(NSString*)_path;
|
||||
|
||||
/**
|
||||
删除文件
|
||||
@param _path 文件路径
|
||||
@returns 成功返回yes
|
||||
*/
|
||||
+ (BOOL)deleteFileAtPath:(NSString*)_path;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/**
|
||||
生成文件路径
|
||||
@param _fileName 文件名
|
||||
@param _type 文件类型
|
||||
@returns 文件路径
|
||||
*/
|
||||
+ (NSString*)getPathByFileName:(NSString *)_fileName;
|
||||
+ (NSString*)getPathByFileName:(NSString *)_fileName ofType:(NSString *)_type;
|
||||
|
||||
/**
|
||||
获取录音设置
|
||||
@returns 录音设置
|
||||
*/
|
||||
+ (NSDictionary*)getAudioRecorderSettingDict;
|
||||
@end
|
||||
132
msext/Class/record/VoiceRecorderBaseVC.m
Executable file
@@ -0,0 +1,132 @@
|
||||
//
|
||||
// VoiceRecorderBaseVC.m
|
||||
// Jeans
|
||||
//
|
||||
// Created by Jeans on 3/23/13.
|
||||
// Copyright (c) 2013 Jeans. All rights reserved.
|
||||
//
|
||||
|
||||
#import "VoiceRecorderBaseVC.h"
|
||||
|
||||
@interface VoiceRecorderBaseVC ()
|
||||
@end
|
||||
|
||||
@implementation VoiceRecorderBaseVC
|
||||
@synthesize vrbDelegate,maxRecordTime,recordFileName,recordFilePath;
|
||||
|
||||
|
||||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
||||
{
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if (self) {
|
||||
// Custom initialization
|
||||
maxRecordTime = kDefaultMaxRecordTime;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
- (void)dealloc{
|
||||
[recordFilePath release];
|
||||
[recordFileName release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
/**
|
||||
生成当前时间字符串
|
||||
@returns 当前时间字符串
|
||||
*/
|
||||
+ (NSString*)getCurrentTimeString
|
||||
{
|
||||
NSDateFormatter *dateformat=[[[NSDateFormatter alloc]init]autorelease];
|
||||
[dateformat setDateFormat:@"yyyyMMddHHmmss"];
|
||||
return [dateformat stringFromDate:[NSDate date]];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
获取缓存路径
|
||||
@returns 缓存路径
|
||||
*/
|
||||
+ (NSString*)getCacheDirectory
|
||||
{
|
||||
return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
|
||||
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
return [[paths objectAtIndex:0]stringByAppendingPathComponent:@"Voice"];
|
||||
}
|
||||
|
||||
/**
|
||||
判断文件是否存在
|
||||
@param _path 文件路径
|
||||
@returns 存在返回yes
|
||||
*/
|
||||
+ (BOOL)fileExistsAtPath:(NSString*)_path
|
||||
{
|
||||
return [[NSFileManager defaultManager] fileExistsAtPath:_path];
|
||||
}
|
||||
|
||||
/**
|
||||
删除文件
|
||||
@param _path 文件路径
|
||||
@returns 成功返回yes
|
||||
*/
|
||||
+ (BOOL)deleteFileAtPath:(NSString*)_path
|
||||
{
|
||||
return [[NSFileManager defaultManager] removeItemAtPath:_path error:nil];
|
||||
}
|
||||
|
||||
/**
|
||||
生成文件路径
|
||||
@param _fileName 文件名
|
||||
@param _type 文件类型
|
||||
@returns 文件路径
|
||||
*/
|
||||
+ (NSString*)getPathByFileName:(NSString *)_fileName ofType:(NSString *)_type
|
||||
{
|
||||
NSString* fileDirectory = [[[VoiceRecorderBaseVC getCacheDirectory]stringByAppendingPathComponent:_fileName]stringByAppendingPathExtension:_type];
|
||||
return fileDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
生成文件路径
|
||||
@param _fileName 文件名
|
||||
@returns 文件路径
|
||||
*/
|
||||
+ (NSString*)getPathByFileName:(NSString *)_fileName{
|
||||
NSString* fileDirectory = [[VoiceRecorderBaseVC getCacheDirectory]stringByAppendingPathComponent:_fileName];
|
||||
return fileDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
获取录音设置
|
||||
@returns 录音设置
|
||||
*/
|
||||
+ (NSDictionary*)getAudioRecorderSettingDict
|
||||
{
|
||||
NSDictionary *recordSetting = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
[NSNumber numberWithFloat: 8000.0],AVSampleRateKey, //采样率
|
||||
[NSNumber numberWithInt: kAudioFormatLinearPCM],AVFormatIDKey,
|
||||
[NSNumber numberWithInt:16],AVLinearPCMBitDepthKey,//采样位数 默认 16
|
||||
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,//通道的数目
|
||||
// [NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,//大端还是小端 是内存的组织方式
|
||||
// [NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,//采样信号是整数还是浮点数
|
||||
// [NSNumber numberWithInt: AVAudioQualityMedium],AVEncoderAudioQualityKey,//音频编码质量
|
||||
nil];
|
||||
return [recordSetting autorelease];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
BIN
msext/Class/record/img/record_animate_01.png
Executable file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
msext/Class/record/img/record_animate_02.png
Executable file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
msext/Class/record/img/record_animate_03.png
Executable file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
msext/Class/record/img/record_animate_04.png
Executable file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
msext/Class/record/img/record_animate_05.png
Executable file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
msext/Class/record/img/record_animate_06.png
Executable file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
msext/Class/record/img/record_animate_07.png
Executable file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
msext/Class/record/img/record_animate_08.png
Executable file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
msext/Class/record/img/record_animate_09.png
Executable file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
msext/Class/record/img/record_animate_10.png
Executable file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
msext/Class/record/img/record_animate_11.png
Executable file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
msext/Class/record/img/record_animate_12.png
Executable file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
msext/Class/record/img/record_animate_13.png
Executable file
|
After Width: | Height: | Size: 6.4 KiB |
BIN
msext/Class/record/img/record_animate_14.png
Executable file
|
After Width: | Height: | Size: 6.7 KiB |