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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -