Swift3でmp3再生する方法[完全版]
ターミナルでファイルを投げ込めばフルパスがわかります。フレームワークaudiotoolbox
を追加します。
import Photos
var soundId:SystemSoundID = 0
// システムサウンドへのパスを指定
if let soundUrl:NSURL = NSURL(fileURLWithPath: "/Users/ryosukehujisawa/Desktop/App/sound/decision.mp3") {
// SystemsoundIDを作成して再生実行
AudioServicesCreateSystemSoundID(soundUrl, &soundId)
AudioServicesPlaySystemSound(soundId)
}