ios開發——實用技術篇Swift篇&系統聲音

來源:互聯網
上載者:User

標籤:

系統聲音

 

 1 // MARK: - 系統聲音 2     /*----- 系統聲音 ------*/ 3     @IBAction func systemSound() 4     { 5         //建立的SystemSoundID對象 6         var soundID: SystemSoundID = 0 7          8         //擷取音效檔地址 9         var path = NSBundle.mainBundle().pathForResource("SaoMa", ofType: "wav")10         11         //地址轉換12         var baseURL = NSURL(fileURLWithPath: path!)13         14         //賦值15         AudioServicesCreateSystemSoundID(baseURL , &soundID)16         17         //使用AudioServicesPlaySystemSound播放18         AudioServicesPlaySystemSound(soundID)19     }20     21     /*----- 系統提醒 ------*/22     @IBAction func systemAlert()23     {24         //建立的SystemSoundID對象25         var soundID: SystemSoundID = 026         27         //擷取音效檔地址28         var path = NSBundle.mainBundle().pathForResource("SaoMa", ofType: "wav")29         30         //地址轉換31         var baseURL = NSURL(fileURLWithPath: path!)32         33         //賦值34         AudioServicesCreateSystemSoundID(baseURL , &soundID)35         36         //使用AudioServicesPlayAlertSound播放37         AudioServicesPlayAlertSound(soundID)38 39     }40     41     /*----- 系統震動 ------*/42     @IBAction func systemVibration()43     {44          //建立的SystemSoundID對象45         var soundID = SystemSoundID(kSystemSoundID_Vibrate)46         47         //使用AudioServicesPlaySystemSound播放48         AudioServicesPlaySystemSound(soundID)49     }

 

 

ios開發——實用技術篇Swift篇&系統聲音

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.