mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Fixed some issues with voice messages when sent from a bridge. (#2190)
This commit is contained in:
@@ -438,6 +438,11 @@ class AudioPlayerMock: AudioPlayerProtocol {
|
||||
}
|
||||
var underlyingActions: AnyPublisher<AudioPlayerAction, Never>!
|
||||
var mediaSource: MediaSourceProxy?
|
||||
var duration: TimeInterval {
|
||||
get { return underlyingDuration }
|
||||
set(value) { underlyingDuration = value }
|
||||
}
|
||||
var underlyingDuration: TimeInterval!
|
||||
var currentTime: TimeInterval {
|
||||
get { return underlyingCurrentTime }
|
||||
set(value) { underlyingCurrentTime = value }
|
||||
@@ -1082,6 +1087,11 @@ class KeychainControllerMock: KeychainControllerProtocol {
|
||||
}
|
||||
class MediaPlayerMock: MediaPlayerProtocol {
|
||||
var mediaSource: MediaSourceProxy?
|
||||
var duration: TimeInterval {
|
||||
get { return underlyingDuration }
|
||||
set(value) { underlyingDuration = value }
|
||||
}
|
||||
var underlyingDuration: TimeInterval!
|
||||
var currentTime: TimeInterval {
|
||||
get { return underlyingCurrentTime }
|
||||
set(value) { underlyingCurrentTime = value }
|
||||
|
||||
@@ -34,7 +34,7 @@ enum AudioPlayerStateIdentifier {
|
||||
@MainActor
|
||||
class AudioPlayerState: ObservableObject, Identifiable {
|
||||
let id: AudioPlayerStateIdentifier
|
||||
let duration: Double
|
||||
private(set) var duration: Double
|
||||
let waveform: EstimatedWaveform
|
||||
@Published private(set) var playbackState: AudioPlayerPlaybackState
|
||||
/// It's similar to `playbackState`, with the a difference: `.loading`
|
||||
@@ -134,8 +134,12 @@ class AudioPlayerState: ObservableObject, Identifiable {
|
||||
case .didStartLoading:
|
||||
playbackState = .loading
|
||||
case .didFinishLoading:
|
||||
playbackState = .readyToPlay
|
||||
if let audioPlayerDuration = audioPlayer?.duration, audioPlayerDuration != duration {
|
||||
MXLog.info("updating duration: \(duration) -> \(audioPlayerDuration)")
|
||||
duration = audioPlayerDuration
|
||||
}
|
||||
fileURL = audioPlayer?.url
|
||||
playbackState = .readyToPlay
|
||||
case .didStartPlaying:
|
||||
if let audioPlayer {
|
||||
await restoreAudioPlayerState(audioPlayer: audioPlayer)
|
||||
|
||||
@@ -26,7 +26,7 @@ enum MediaPlayerState {
|
||||
|
||||
protocol MediaPlayerProtocol: AnyObject {
|
||||
var mediaSource: MediaSourceProxy? { get }
|
||||
|
||||
var duration: TimeInterval { get }
|
||||
var currentTime: TimeInterval { get }
|
||||
var url: URL? { get }
|
||||
var state: MediaPlayerState { get }
|
||||
|
||||
@@ -56,7 +56,7 @@ class VoiceMessageMediaManager: VoiceMessageMediaManagerProtocol {
|
||||
let loadFileBgTask = await backgroundTaskService?.startBackgroundTask(withName: "LoadFile: \(source.url.hashValue)")
|
||||
defer { loadFileBgTask?.stop() }
|
||||
|
||||
guard let mimeType = source.mimeType, mimeType == supportedVoiceMessageMimeType else {
|
||||
guard let mimeType = source.mimeType, mimeType.starts(with: supportedVoiceMessageMimeType) else {
|
||||
throw VoiceMessageMediaManagerError.unsupportedMimeTye
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user