Last active
January 7, 2023 23:30
-
-
Save melvinbeemer/ed52b8efa7b3ffeb901a to your computer and use it in GitHub Desktop.
Check if AVPlayer is currently playing an item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import AVFoundation | |
extension AVPlayer { | |
var isPlaying: Bool { | |
if (self.rate != 0 && self.error == nil) { | |
return true | |
} else { | |
return false | |
} | |
} | |
} |
player.timeControlStatus == AVPlayer.TimeControlStatus.playing
Also this works for it
Thanks @nodahikaru that works for me
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can one line it by doing
return (self.player.rate != 0 && self.player.error == nil)