mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-23 18:12:44 +02:00
Fix #7325: prevent setting the audio session to inactive during recording Fix #7217: ensure that an audio player has its content loaded when it reaches the end to allow seek and replay.
This commit is contained in:
@@ -53,7 +53,7 @@ class VoiceMessageAudioPlayer: NSObject {
|
||||
return false
|
||||
}
|
||||
|
||||
return (audioPlayer.rate > 0)
|
||||
return audioPlayer.currentItem != nil && (audioPlayer.rate > 0)
|
||||
}
|
||||
|
||||
var duration: TimeInterval {
|
||||
@@ -118,6 +118,13 @@ class VoiceMessageAudioPlayer: NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
func reloadContentIfNeeded() {
|
||||
if let url, let audioPlayer, audioPlayer.currentItem == nil {
|
||||
self.url = nil
|
||||
loadContentFromURL(url)
|
||||
}
|
||||
}
|
||||
|
||||
func removeAllPlayerItems() {
|
||||
audioPlayer?.removeAllItems()
|
||||
}
|
||||
@@ -130,6 +137,8 @@ class VoiceMessageAudioPlayer: NSObject {
|
||||
func play() {
|
||||
isStopped = false
|
||||
|
||||
reloadContentIfNeeded()
|
||||
|
||||
do {
|
||||
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback)
|
||||
try AVAudioSession.sharedInstance().setActive(true)
|
||||
|
||||
Reference in New Issue
Block a user