Skip to content

Instantly share code, notes, and snippets.

@ahmadnaser
Created November 13, 2016 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmadnaser/a4589152d0c7ae5fe44094e3647c7e5f to your computer and use it in GitHub Desktop.
Save ahmadnaser/a4589152d0c7ae5fe44094e3647c7e5f to your computer and use it in GitHub Desktop.
//Shared on Ahmad Naser.com
func PlayAudioInSwift3() {
var player = AVAudioPlayer()
let audioPath = Bundle.main().pathForResource("2-loader", ofType: "mp3")
do {
try player = AVAudioPlayer(contentsOf: URL(fileURLWithPath: audioPath!))
player.play()
} catch {
// process error
}
Thread.sleep(forTimeInterval: 1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment