var myString = "Hello world! - swift.jsrun.net"
print(myString)
//
//ViewController,swift
BridSound
//
//Created by ZHIFENG chen on 2020/8/3.
Copyright © 2020 Zhifeng Chen.All rights reserved.
//
import UIKit
//导入音频支持库
import AVFoundation
class ViewController:UIViewController {
//播音器变量
var soundPlayer : AVFoundioPlayer!
@IBAction funce onClicked(_sender: UIButton){
//从沙盒中读取文件所在路径,文件名为bird.mp3
let path=Bundle.main.path(forResource:"bird",ofType:"mp3")
//将路径转化为URL
let url =URL(fileURLWithPath:path!)
//调用AVAudioPlayer 函数,生成播放器
soundPlayer =try ? AVFoundioPlayer(contentsOf:url)
//播放器播放声音,默认是循环播放方式
soundPlayer.play()
}
}