swift - Load .m4a file from disk into NSData object - iOS -


i recorded users voice avaudiorecorder , saved .m4a file in documents folder. when trying load .m4a file nsdataobject, object nil.
.m4a file contains sound , used file path correct.
using following line load .m4a file:

let sounddata = nsfilemanager.defaultmanager().contentsatpath(soundpath) println("\(sounddata)") // prints nil   

it appears avaudioplayer requires path "file://" prefix, while sfilemanager.defaultmanager().contentsatpath() needs prefix removed path in order work properly. try removing doing like:

soundpath = soundpath.stringbyreplacingoccurrencesofstring("file://", withstring: "", options: nsstringcompareoptions.literalsearch, range: nil) 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -