• Xcode9学习笔记63


    import UIKit
    import AudioToolbox//导入音频工具箱框架,这样就可以使用系统声音服务了
    
    class ViewController: UIViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
            // Do any additional setup after loading the view, typically from a nib.
            
            var _soundId:SystemSoundID = 0//声明一个系统声音标识的声音变量
            let path = Bundle.main.path(forResource: "sheep", ofType: "mp3")//获取沙箱目录中,声音文件的所在路径
            let soundUrl = URL(fileURLWithPath: path!)//将字符串路径转换成网址路径
            //对于按键音、下拉菜单音等较短暂的声音,以及震动效果,可以使用系统音频服务来播放
            AudioServicesCreateSystemSoundID(soundUrl as CFURL, &_soundId)
            AudioServicesPlaySystemSound(_soundId)
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    
    
    }
    

      

  • 相关阅读:
    Java Mybatis 传参方式
    html Js跨域提交数据方法,跨域提交数据后台获取不到数据
    uuidgen
    shell 案例
    docker搭建tomcat环境
    redis主从+哨兵模式(借鉴)
    ansible-playbook 案例
    NFS
    mysql -sql语句
    定时任务crontab命令
  • 原文地址:https://www.cnblogs.com/LisenH/p/7858988.html
Copyright © 2020-2023  润新知