Why does AVPlayer download first and not stream?

This is the first time I am working with AVPlayer, and I want to play an mp3 file using a live HTTP request. I use AVPlayer , which works great to play mp3 files, but the problem in AVPlayer is to download mp3 first and then play it. I do not know why AVPlayer downloads the file and then plays it instead of the live game. My Xcode 8.2.1 and I use Swift 3.

Here is my code snippet.

 var audioPlayer = AVPlayer() var avplayerItem : AVPlayerItem? override func viewDidLoad() { super.viewDidLoad() let fileurl:URL = URL(string : "http://www.noiseaddicts.com/samples_1w72b820/2514.mp3")! avplayerItem = AVPlayerItem(url : fileurl) audioPlayer = AVPlayer(playerItem : avplayerItem) audioPlayer.rate = 1.0 audioPlayer.play() } 

In the case of AVPlayer need to download the entire file before playing it, what should I do for live transmission?

Thanks.

+5
source share

Source: https://habr.com/ru/post/1262513/


All Articles