Autoplay mp3 from a URL

0 votes
64 views
asked Mar 25 in Swift by anonymous
HI

  Is there any posibility to play the mp3 from URL and auto play too.

1 Answer

0 votes
answered Mar 25 by admin (8,115 points)

HI 

  Try this piece code.

var url = URL(string: "http://marc.ucla.edu/mpeg/01_Breathing_Meditation.mp3")
playerItem = AVPlayerItem(url)
player = AVPlayer.withPlayerItem(playerItem)
player = AVPlayer.withURL(url)
player.play()
...