Recording of iOS development

Source: Internet
Author: User

Why should the recording alone to write, just because this is relatively simple, but because he is relatively simple, causing me a long time to ignore it, but when I think of it, suddenly forget I have learned this thing, in this, really is to think of all a little blush .... -。 -! ;

Recording:

Related class Description:

(1) Avaudioplayer

(2) Setting

<1>avnumberofchannelskey Number of channels

<2>avsampleratekey Sample Rate 44100

<3>avlinearpcmbitdepthkey bit LV 16 32

<4>avencoderaudioqualitykey Quality

<5>avencoderbitratekey bit sampling LV 128000

(3) Use

1. Initialization

2. Start recording

3. Stop Recording

Nonsense not much to say, we directly on the code;

How to Record

-(void) Startaudiorecoder: (UIButton *) sender{

/**

URL: is a local url,recodeer requires a stored path

*/

sender.selected =!sender.selected;

if (Sender.selected!=yes) {

[Recorder stop];

Return

}

NSString * name = [NSString stringwithformat:@ "%d.aiff", (int) [NSDate date].timeintervalsince1970];

NSString *path = [[Nssearchpathfordirectoriesindomains (Nscachesdirectory, Nsuserdomainmask, YES) LastObject] Stringbyappendingpathcomponent:name];

Nserror *error;

Recorder = [[Avaudiorecorder alloc]initwithurl:[nsurl Urlwithstring:path] settings:@{avnumberofchannelskey:@2, avsampleratekey:@44100,avlinearpcmbitdepthkey:@32,avencoderaudioqualitykey:@ (AVAudioQualityMax), avencoderbitratekey:@128000} error:&error];

/**

* Avnumberofchannelskey channel number is usually dual Channel 2

* Avsampleratekey sampling rate Hertz-"44100

* Avlinearpcmbitdepthkey Bit rate 8 16 24 32

* The quality of the avencoderaudioqualitykey sound needs to be an enumeration

Avaudioqualitymin = 0,

Avaudioqualitylow = 0x20,

Avaudioqualitymedium = 0x40,

Avaudioqualityhigh = 0x60,

Avaudioqualitymax = 0x7F

* Avencoderbitratekey audio encoded bit rate bps transfer rate 128000bps

*/

[Recorder Preparetorecord];

[Recorder record];

NSLog (@ "%@", Path);

}

Call at the end of the recording

-(void) audiorecorderdidfinishrecording: (Avaudiorecorder *) Recorder successfully: (BOOL) flag{

Where to store files

NSString *path = [Nssearchpathfordirectoriesindomains (nscachesdirectory, Nsuserdomainmask, YES) lastObject];

I'm here. The class that references the file operation

Nsfilemanager *manager = [Nsfilemanager Defaultmanager];

Get the files under all paths

Nsarray *pathlist = [manager Subpathsatpath:path];

Nsmutablearray *audiopathlist = [Nsmutablearray array];

For (NSString *audiopath in pathList) {

Differentiate between files that are needed by comparing extension names

if ([Audiopath.pathextension isequaltostring:@ "AIFF"]) {

Put the filtered files in the array

[Audiopathlist Addobject:audiopath];

}

}

NSLog (@ "%@", audiopathlist);

}

Must remember, I have learned the recording, can not learn after and did not learn the same, it is a sin ancient;;;;;;;;;

Recording of iOS development

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.