AVPlayer 与 AVAudioPlayer

2023-10-23移动开发问题
0

本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

恢复游戏 cocos2d
Resume game cocos2d(恢复游戏 cocos2d)...
2024-08-12 移动开发问题
6

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

如何将 32 位 PNG 转换为 RGB565?
How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)...
2024-08-12 移动开发问题
21