Iphone – AVPlayer vs. AVAudioPlayer

audiocore-audioios4iphonestreaming

The documentation for AVPlayer states the following:

[The] player works equally well with local and remote media files

However, the documentation for AVAudioPlayer states the following:

Apple recommends that you use this class for audio playback unless you are playing audio captured from a network stream

For the work I am doing I need some of the capabilities of AVAudioPlayer, but all my audio is being streamed. The main thing I need from AVAudioPlayer that AVPlayer does not have is the "playing" property. It is difficult to build a player UI without that property, among others.

So what is the difference between AVPlayer and AVAudioPlayer that makes the latter unsuitable for network streaming? Is there a way to get some of the info from AVPlayer that AVAudioPlayer provides such as the "playing" property?

Best Answer

  1. AVPlayer can play from AVPlayerItem using AVURLAsset with an iPod library url. The AVAudioPlayer cannot play from an iPod library url.

  2. AVPlayer has no volume property and requires the use of the system volume setting which can be controlled only by the hardware switch or an MPVolumeView. But you can set the mix volume of AVAudioPlayer.

  3. AVPlayer seems to report an incorrect currentTime after seeking. But AVAudioPlayer reports accurately.

Related Topic