ios - 我怎么知道 AVAudioPlayer 是否暂停了?

标签 ios swift cocoa-touch avfoundation avplayer

发现是否 AVAudioPlayer对象正在播放,我可以简单地使用 isPlaying 属性:

if audioPlayer.isPlaying {
    // ...
}

如果音频播放器没有播放,我如何区分它是暂停还是停止?

我不能为此目的使用 currentTime 属性。这是因为如果我调用 stop(),那么当前时间将停留在调用时的任何时间,这与 pause() 时的行为相同> 被调用。

最佳答案

我认为这就像在 View Controller 类中保留一个 BOOL 属性一样简单,该属性在单击播放/恢复按钮时设置为 YES,在按下停止/暂停按钮时设置为 NO。

关于ios - 我怎么知道 AVAudioPlayer 是否暂停了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39744929/

相关文章:

swift - 使用变量访问元组的值

ios - 为什么我的 Apple Watch 并发症没有显示任何东西?

iphone - 苹果使用哪种字体和大小作为导航栏标题?

ios - 安装 iOS 应用程序后的深度链接(延迟深度链接)

ios - 如何使用UIPickerView的选定值作为通知的content.sound?

ios - 在 Swift 中从字典中获取值时崩溃

objective-c - 连接到多个 Controller 的 iOS subview 小部件

ios - 在 iOS 中查看层次结构

ios - 迪尔德 : Symbol not found: _OBJC_CLASS_$_NSNetService Error

ios - 不在 set updateConstraints 中时,UIStackView 间距会打破约束