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 nsdata
object, 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
Post a Comment