xcode6 - Swift - save audio recordings -
it much appreciated if can help me following.
i want record sound , display on table view.
i have got recording part
func setuprecorder() { var format = nsdateformatter() format.dateformat="yyyy-mm-dd-hh-mm-ss" var currentfilename = nametextfield.text println(currentfilename) var dirpaths = nssearchpathfordirectoriesindomains(.documentdirectory, .userdomainmask, true) var docsdir: anyobject = dirpaths[0] var soundfilepath = docsdir.stringbyappendingpathcomponent(currentfilename) soundfileurl = nsurl(fileurlwithpath: soundfilepath) allow filemanager = nsfilemanager.defaultmanager() if filemanager.fileexistsatpath(soundfilepath) { // won't happen. want it? println("sound exists") } var recordsettings = [ avformatidkey: kaudioformatapplelossless, avencoderaudioqualitykey : avaudioquality.max.toraw(), avencoderbitratekey : 320000, avnumberofchannelskey: 2, avsampleratekey : 44100.0 ] var error: nserror? recorder = avaudiorecorder(url: soundfileurl!, settings: recordsettings, error: &error) if allow e = error { println(e.localizeddescription) } else { recorder.delegate = self recorder.meteringenabled = true recorder.preparetorecord() // creates/overwrites file @ soundfileurl }`
i using model consists of 2 properties.(title"string" , media"recording")
having problem saving audio(nsurl) , displaying on tableview.
i noob can see , help great!
thanks
most you'll need session created:
var session=avaudiosession.sharedinstance() session.setcategory(avaudiosessioncategoryplayandrecord,error:nil)
swift xcode6 avfoundation avaudiorecorder
No comments:
Post a Comment