Swiftui Play Mp3

[Solved] Swiftui Play Mp3 | Swift - Code Explorer | yomemimo.com
Question : swiftui play mp3

Answered by : adorable-angelfish-q9qh9mcdbb7x

import AVFoundation
var bombSoundEffect: AVAudioPlayer?
let path = Bundle.main.path(forResource: "example.mp3", ofType:nil)!
let url = URL(fileURLWithPath: path)
do { bombSoundEffect = try AVAudioPlayer(contentsOf: url) bombSoundEffect?.play()
} catch { // couldn't load file :(
}

Source : | Last Update : Sun, 27 Dec 20

Answers related to swiftui play mp3

Code Explorer Popular Question For Swift