AVPlayer 与 AVAudioPlayer [英] AVPlayer vs. AVAudioPlayer

查看:16
本文介绍了AVPlayer 与 AVAudioPlayer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AVPlayer 的文档声明如下:

[The] 播放器同样适用于本地和远程媒体文件

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

但是,AVAudioPlayer 的文档 声明如下:

Apple 建议您使用此类进行音频播放,除非您正在播放从网络流中捕获的音频

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

对于我正在做的工作,我需要 AVAudioPlayer 的一些功能,但我所有的音频都是流式传输的.我需要从 AVAudioPlayer 获得的 AVPlayer 没有的主要内容是正在播放"属性.没有该属性就很难构建播放器 UI.

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.

那么 AVPlayer 和 AVAudioPlayer 有什么区别使得后者不适合网络流媒体?有没有办法从 AVAudioPlayer 提供的 AVPlayer 中获取一些信息,例如正在播放"属性?

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?

推荐答案

  1. AVPlayer 可以使用带有 iPod 库 URL 的 AVURLAsset 从 AVPlayerItem 播放.AVAudioPlayer 无法从 iPod 库 url 播放.

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

AVPlayer 没有音量属性,需要使用只能由硬件开关或 MPVolumeView 控制的系统音量设置.但是你可以设置 AVAudioPlayer 的混音音量.

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.

AVPlayer 在搜索后似乎报告了错误的 currentTime.但 AVAudioPlayer 报告准确.

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

这篇关于AVPlayer 与 AVAudioPlayer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆