mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Autoplay the next voice message if it is the next timeline item. (#6089)
This commit is contained in:
@@ -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? {
|
||||
|
||||
Reference in New Issue
Block a user