Autoplay the next voice message if it is the next timeline item. (#6089)

This commit is contained in:
Mauro
2026-09-01 18:00:14 +02:00
committed by GitHub
parent b4a36ad465
commit 86bc4d54b6
13 changed files with 463 additions and 16 deletions
@@ -6,11 +6,14 @@
// Please see LICENSE files in the repository root for full details.
//
import AVFoundation
import Foundation
class MediaPlayerProvider: MediaPlayerProviderProtocol {
private lazy var audioPlayer = AudioPlayer()
private var audioPlayerStates: [String: AudioPlayerState] = [:]
/// Held onto for the duration of the playback, an unowned player is silent.
private var soundEffectPlayer: AVAudioPlayer?
var player: AudioPlayerProtocol {
audioPlayer
@@ -55,6 +58,17 @@ class MediaPlayerProvider: MediaPlayerProviderProtocol {
}
}
/// Doesn't configure an audio session, so that it can be used alongside any existing player or session.
func play(soundEffect: SoundEffect) {
do {
let player = try AVAudioPlayer(contentsOf: soundEffect.fileURL)
soundEffectPlayer = player
player.play()
} catch {
MXLog.error("Failed playing the sound effect: \(error)")
}
}
// MARK: - Private
private func audioPlayerStateID(for identifier: AudioPlayerStateIdentifier) -> String? {