2

I'm streaming audio in my iOS swift app.
The main issue is that avplayer has to load all the file to start the playback.
Using playImmediatelyAtRate doesn't work because playbackBufferEmpty is always true until the file is completely downloaded which can be an issue on long audio files.

Any ideas?

L.L
  • 43
  • 5
  • You can use STKAudioPlayer for this. [The link](https://github.com/tumtumtum/StreamingKit) for StreamingKit is here, go through it. – Jaydip Godhani Apr 06 '18 at 10:37
  • I was mostly looking for a solution that allowed me to keep avplayer as is – L.L Apr 06 '18 at 14:47

2 Answers2

0

Not really AVPlayer related answer but you could use VLCKit to handle the stream.

Here is a basic sample in Swift:

let mediaPlayer = VLCMediaPlayer()

// replace streamURL by the url of the stream
mediaPlayer.media = VLCMedia(url: streamURL)

// outputView is the view where you want to display the stream
mediaPlayer.drawable = outputView
mediaPlayer.play()

If you have any issue with VLCKit, feel free to ping me!

bubu
  • 333
  • 2
  • 9
0

For iOS >10 I set: avplayer.automaticallyWaitsToMinimizeStalling = false; and that seemed to fix it for me. This could have other consequences, but I haven't hit those yet.

I got the idea for it from: AVPlayer stops playing video after buffering

grizzb
  • 329
  • 5
  • 8