AVPlayer vs. AVAudioPlayer

心已入冬 提交于 2019-11-29 20:45:53
  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.

Cœur

7 years after...

From a point of view with dependence on Swift and CocoaPods, so my answer is comparing for iOS 8+ only.

1. iPod library support

identical support since iOS6

2. volume control

identical support:

3. seeking control

both AVPlayer and AVAudioPlayer seem to report an incorrect currentTime after seeking:

4. changing source

  • you need only one AVPlayer to play multiple files
  • you need multiple AVAudioPlayer to play multiple files
tadejsv

The AVPlayer actually has a similar property as the playing property of AVAudioPlayer. Take a look at the rate property.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!