Guest User

Untitled

a guest
Dec 13th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import AVFoundation
  2.  
  3. class Music1ViewController: UIViewController {
  4.  
  5. //5 -
  6. var songPlayer = AVAudioPlayer()
  7. //15 -
  8. var hasBeenPaused = false
  9.  
  10. //6 -
  11. func prepareSongAndSession() {
  12.  
  13. do {
  14. //7 - Insert the song from our Bundle into our AVAudioPlayer
  15. songPlayer = try AVAudioPlayer(contentsOf: URL.init(fileURLWithPath: Bundle.main.path(forResource: "localsong", ofType: "mp3")!))
  16. //8 - Prepare the song to be played
  17. songPlayer.prepareToPlay()
  18.  
  19. songPlayer = try AVAudioPlayer(contentsOf: URL(string: "https://s3.amazonaws.com/kargopolov/kukushka.mp3")!)
Add Comment
Please, Sign In to add comment