成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

詳解IPhone之 AVAudioRecorder 代碼實現

移動開發 iOS
本文介紹的是詳解IPhone之 AVAudioRecorder 代碼實現,很好的一篇文章,與友們分享一下,我們一起來看內容。

詳解IPhoneAVAudioRecorder 代碼實現是本文要介紹的內容,內容不多,基本屬于代碼實現。我們來看詳細內容。

#import <AVFoundation/AVFoundation.h>  需要引入

  1. //獲取document目錄的路徑  
  2. - (NSString*) documentsPath {  
  3.  if (! _documentsPath) {  
  4.   NSArray *searchPaths =  
  5.    NSSearchPathForDirectoriesInDomains 
  6.    (NSDocumentDirectory, NSUserDomainMask, YES);  
  7.   _documentsPath = [searchPaths objectAtIndex: 0];  
  8.   [_documentsPath retain];  
  9.  }  
  10.  return _documentsPath;  
  11. }  
  12. //(document目錄的路徑)  
  13.  NSString *destinationString = [[self documentsPath]  
  14.    stringByAppendingPathComponent:filenameField.text];  
  15.  NSURL *destinationURL = [NSURL fileURLWithPath: destinationString];  
  16.  
  17. //初始化AVAudioRecorder  
  18.  NSError *recorderSetupError = nil;  
  19.  AVAudioRecorder audioRecorder = [[AVAudioRecorder alloc] initWithURL:destinationURL  
  20.    settings:recordSettings error:&recorderSetupError];   
  21.  [recordSettings release]; 

第二個參數  settings是一個容納鍵值對的NSDictionary有四種一般的鍵

1、一般的音頻設置

2、線性PCM設置

3、編碼器設置

4、采樣率轉換設置

  1. NSMutableDictionary  需要加入五個設置值(線性PCM)  
  2.  
  3. NSMutableDictionary *recordSettings =  
  4.   [[NSMutableDictionary alloc] initWithCapacity:10];  
  5.  
  6.   //1 ID號  
  7.   [recordSettings setObject:  
  8.    [NSNumber numberWithInt: kAudioFormatLinearPCM] forKey: AVFormatIDKey];  
  9.   float sampleRate =  
  10.    [pcmSettingsViewController.sampleRateField.text floatValue];  
  11.   //2 采樣率  
  12.   [recordSettings setObject:  
  13.    [NSNumber numberWithFloat:sampleRate] forKey: AVSampleRateKey];  
  14.     
  15.   //3 通道的數目  
  16.   [recordSettings setObject:  
  17.    [NSNumber numberWithInt:  
  18.     (pcmSettingsViewController.stereoSwitch.on ? 2 : 1)]  
  19.    forKey:AVNumberOfChannelsKey];  
  20.   int bitDepth =  
  21.    [pcmSettingsViewController.sampleDepthField.text intValue];  
  22.     
  23.   //4 采樣位數  默認 16  
  24.   [recordSettings setObject:  
  25.    [NSNumber numberWithInt:bitDepth] forKey:AVLinearPCMBitDepthKey];  
  26.     
  27.   //5  
  28.   [recordSettings setObject:  
  29.    [NSNumber numberWithBool:  
  30.      pcmSettingsViewController.bigEndianSwitch.on]  
  31.     forKey:AVLinearPCMIsBigEndianKey];  
  32.  
  33.  
  34.   //6 采樣信號是整數還是浮點數  
  35.   [recordSettings setObject:  
  36.    [NSNumber numberWithBool:  
  37.      pcmSettingsViewController.floatingSamplesSwitch.on]  
  38.     forKey:AVLinearPCMIsFloatKey]; 

AVAudioRecorder成功創建后,使用他非常直接.它的三個基本方法如下

  1. -(void) startRecording {  
  2.  [audioRecorder record];  
  3. }  
  4.  
  5. -(void) pauseRecording {  
  6.  [audioRecorder pause];  
  7.  recordPauseButton.selected = NO;  
  8. }  
  9.  
  10. -(void) stopRecording {  
  11.  [audioRecorder stop];  

小結:詳解IPhoneAVAudioRecorder的內容介紹完了,希望本文對你有所幫助!

責任編輯:zhaolei 來源: 互聯網
相關推薦

2011-08-11 17:32:51

iPhone視圖

2011-07-18 14:39:53

iPhone SDK UIKit

2011-07-28 10:11:54

iPhone開發 備忘

2011-08-18 10:59:57

iPhone開發消息通信NSNotificat

2011-08-17 15:19:38

iPhone應用數據

2011-08-12 14:04:53

iPhone動畫

2011-07-27 11:19:33

iPhone UITableVie

2011-08-18 15:40:20

iPhone文本切頁

2011-07-29 13:55:10

IPhone 動畫

2011-06-03 10:19:59

iphone Objective-

2011-08-16 15:36:47

iPhone應用測試

2011-07-20 17:29:12

iPhone 網絡

2011-07-25 14:44:41

iPhone iPhone開發 截屏

2011-07-29 15:47:21

iPhone開發 Objective- C

2021-05-08 07:57:17

ServletFilter設計模式

2011-08-08 10:42:46

iPhone UITableVie 分頁

2011-08-18 09:44:33

iPhone SDK儀表控件UIDialView

2011-07-27 15:47:09

iPhone Simulator 文件

2011-08-01 13:13:19

iPhone開發 圖片

2011-08-15 11:23:41

iPhone開發循環滾動UIScrollVie
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 成人福利在线 | 秋霞国产 | 久久国产精品久久久久 | 日本一区二区高清不卡 | 中文字幕韩在线第一页 | 成人性生交a做片 | 久久中文字幕在线 | 国产精品资源在线 | 乳色吐息在线观看 | 精品国产91久久久久久 | av男人天堂影院 | 精品国产一区二区国模嫣然 | 中文字幕精品一区久久久久 | 人人做人人澡人人爽欧美 | 一级黄色片在线免费观看 | 黄色毛片免费看 | 久久久天天 | 天天精品在线 | 欧美激情五月 | 国产婷婷在线视频 | 久久伊人精品 | 先锋av资源在线 | 国产福利视频在线观看 | 精品视频一区二区 | 日韩欧美在线播放 | 欧美日韩国产中文 | 黑人成人网 | 亚洲精品一区av在线播放 | 久久激情视频 | 自拍偷拍小视频 | 日韩一区中文字幕 | 99热国产在线播放 | 国产一级电影在线观看 | 一区二区三区精品视频 | 亚洲精品久久久蜜桃 | 久久99视频| 欧美日产国产成人免费图片 | 香蕉婷婷| 给我免费的视频在线观看 | 综合第一页 | 国产日韩欧美电影 |