Fix the delay when switching between voice messages (#1985)

This commit is contained in:
Nicolas Mauri
2023-10-30 20:44:59 +01:00
committed by GitHub
parent 1f1aff21be
commit dbc1704751
2 changed files with 3 additions and 5 deletions

View File

@@ -119,7 +119,6 @@ class AudioPlayer: NSObject, AudioPlayerProtocol {
isStopped = true
internalAudioPlayer?.pause()
internalAudioPlayer?.seek(to: .zero)
try? AVAudioSession.sharedInstance().setActive(false)
}
func seek(to progress: Double) async {

View File

@@ -284,16 +284,15 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
let audioPlayerState = audioPlayerState(for: itemID)
// Detach all other states
await mediaPlayerProvider.detachAllStates(except: audioPlayerState)
// Ensure this one is attached
if !audioPlayerState.isAttached {
audioPlayerState.attachAudioPlayer(audioPlayer)
}
// Detach all other states
await mediaPlayerProvider.detachAllStates(except: audioPlayerState)
guard audioPlayer.mediaSource == source, audioPlayer.state != .error else {
audioPlayer.stop()
// Load content
do {
MXLog.info("Loading voice message audio content from source for itemID \(itemID)")