mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-19 16:13:42 +02:00
#4094 - Added voice messages locked mode playback.
This commit is contained in:
@@ -33,7 +33,6 @@ enum VoiceMessageAudioPlayerError: Error {
|
||||
|
||||
class VoiceMessageAudioPlayer: NSObject {
|
||||
|
||||
private var contentURL: URL!
|
||||
private var playerItem: AVPlayerItem?
|
||||
private var audioPlayer: AVPlayer?
|
||||
|
||||
@@ -44,6 +43,8 @@ class VoiceMessageAudioPlayer: NSObject {
|
||||
|
||||
weak var delegate: VoiceMessageAudioPlayerDelegate?
|
||||
|
||||
private(set) var url: URL?
|
||||
|
||||
var isPlaying: Bool {
|
||||
guard let audioPlayer = audioPlayer else {
|
||||
return false
|
||||
@@ -57,7 +58,9 @@ class VoiceMessageAudioPlayer: NSObject {
|
||||
return 0
|
||||
}
|
||||
|
||||
return CMTimeGetSeconds(item.duration)
|
||||
let duration = CMTimeGetSeconds(item.duration)
|
||||
|
||||
return duration.isNaN ? 0.0 : duration
|
||||
}
|
||||
|
||||
var currentTime: TimeInterval {
|
||||
@@ -76,21 +79,18 @@ class VoiceMessageAudioPlayer: NSObject {
|
||||
removeObservers()
|
||||
}
|
||||
|
||||
override init() {
|
||||
audioPlayer = AVPlayer()
|
||||
}
|
||||
|
||||
func loadContentFromURL(_ url: URL) {
|
||||
if contentURL == url {
|
||||
if self.url == url {
|
||||
return
|
||||
}
|
||||
|
||||
self.url = url
|
||||
|
||||
removeObservers()
|
||||
|
||||
delegate?.audioPlayerDidStartLoading(self)
|
||||
|
||||
contentURL = url
|
||||
playerItem = AVPlayerItem(url: contentURL)
|
||||
|
||||
playerItem = AVPlayerItem(url: url)
|
||||
audioPlayer = AVPlayer(playerItem: playerItem)
|
||||
|
||||
addObservers()
|
||||
|
||||
Reference in New Issue
Block a user