Play sound from Bundle

import AVFoundation var player:AVAudioPlayer? if let path = Bundle.main.path(forResource: "default_rolling", ofType: "wav") { let url = URL(fileURLWithPath: path) do { self.player = try AVAudioPlayer(contentsOf: url) self.player?.prepareToPlay() self.player?.play() } catch { print(error.localizedDescription) } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.