ios9 - My system sound in Swift is not played -
this use:
if let filepath = nsbundle.mainbundle().pathforresource("aurora", oftype: "aiff") { //it doesn't gets here let fileurl = nsurl(fileurlwithpath: filepath) var soundid:systemsoundid = 0 audioservicescreatesystemsoundid(fileurl, &soundid) audioservicesplaysystemsound(soundid) }
how this? i've read lot this, nothing has worked.
testing on real device.
you can use following code:
func getsoundid() -> systemsoundid { var soundid: systemsoundid = 0 let soundurl = cfbundlecopyresourceurl(cfbundlegetmainbundle(), "glass", "mp3", nil) audioservicescreatesystemsoundid(soundurl, &soundid) return soundid } let soundid: systemsoundid = playsound() audioservicesplaysystemsound(soundid)
you can check system playing sound or not putting sound id follows:
audioservicesplaysystemsound(1200)
please check value of system.
Comments
Post a Comment