is still the code that is directly affixed to today's practice
viewcontroller.m//try sound effects////Created by Chen on 15/3/18.//Copyright (c) 2015 LANRW. All rights reserved.//#import "ViewController.h" #import <AVFoundation/AVFoundation.h> @interface Viewcontroller () @property (Nonatomic,strong) Avaudioplayer *av; @property (nonatomic,strong) Avaudiorecorder *rd;@ End@implementation viewcontroller/** * Play sound */-(ibaction) button1: (ID) Sender {nsurl *url = [[NSBundle Mainbundle]urlf orresource:@ "A-game Glitch SYNTH.CAF" Withextension:nil]; Systemsoundid Soundid; Audioservicescreatesystemsoundid (__bridge cfurlref) (URL), &soundid); Audioservicesplayalertsound (Soundid);} /** * Play Music */-(Ibaction) Button2: (ID) Sender {nsurl *url = [[NSBundle mainbundle]urlforresource:@] When you're old. mp3 "Withextens Ion:nil]; _av = [[Avaudioplayer alloc]initwithcontentsofurl:url Error:nil]; [_av Preparetoplay]; [_av play];} /** * Press the recording */-(ibaction) Button3: (ID) Sender {nsstring *path = [Nssearchpathfordirectoriesindomains (nsdocumentdirector Y, NSUSerdomainmask, YES) lastobject]; Path = [path stringbyappendingpathcomponent:@ "Test.wav"]; Nsurl *url = [Nsurl Fileurlwithpath:path]; _RD = [[Avaudiorecorder alloc]initwithurl:url Settings:nil Error:nil]; [_rd Preparetorecord]; [_rd record];} /** * Play up the recording */-(ibaction) Button4: (ID) Sender {[_rd stop];} -(void) viewdidload {[Super viewdidload]; Do any additional setup after loading the view, typically from a nib.} -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} @end
Http://pan.baidu.com/s/1o6A4HV8
Simple Audio for IOS