System sound
1 //MARK:-System sound2 /*-----System Sound------*/3 @IBAction func systemsound ()4 {5 //Systemsoundid object created by6var soundid:systemsoundid =07 8 //get the address of a sound file9var path = Nsbundle.mainbundle (). Pathforresource ("Saoma", OfType:"wav")Ten One //Address Translation Avar BaseURL = Nsurl (fileurlwithpath:path!) - - //Assign Value theAudioservicescreatesystemsoundid (BaseURL, &Soundid) - - //Play with Audioservicesplaysystemsound - Audioservicesplaysystemsound (Soundid) + } - + /*-----System Alert------*/ A @IBAction func systemalert () at { - //Systemsoundid object created by -var soundid:systemsoundid =0 - - //get the address of a sound file -var path = Nsbundle.mainbundle (). Pathforresource ("Saoma", OfType:"wav") in - //Address Translation tovar BaseURL = Nsurl (fileurlwithpath:path!) + - //Assign Value theAudioservicescreatesystemsoundid (BaseURL, &Soundid) * $ //Play with AudioservicesplayalertsoundPanax Notoginseng Audioservicesplayalertsound (Soundid) - the } + A /*-----System Vibration------*/ the @IBAction func systemvibration () + { - //Systemsoundid object created by $var soundid =Systemsoundid (ksystemsoundid_vibrate) $ - //Play with Audioservicesplaysystemsound - Audioservicesplaysystemsound (Soundid) the}
iOS Development--Practical technical article Swift & System sound