diff --git a/ElementX/Sources/Services/Audio/Player/AudioPlayerState.swift b/ElementX/Sources/Services/Audio/Player/AudioPlayerState.swift index 53789fedb..33c975780 100644 --- a/ElementX/Sources/Services/Audio/Player/AudioPlayerState.swift +++ b/ElementX/Sources/Services/Audio/Player/AudioPlayerState.swift @@ -41,7 +41,9 @@ class AudioPlayerState: ObservableObject, Identifiable { /// updates are delayed by a fixed amount of time @Published private(set) var playerButtonPlaybackState: AudioPlayerPlaybackState @Published private(set) var progress: Double - @Published private(set) var showProgressIndicator: Bool + var showProgressIndicator: Bool { + progress > 0 + } private weak var audioPlayer: AudioPlayerProtocol? private var audioPlayerSubscription: AnyCancellable? @@ -65,7 +67,6 @@ class AudioPlayerState: ObservableObject, Identifiable { self.duration = duration self.waveform = waveform ?? EstimatedWaveform(data: []) self.progress = progress - showProgressIndicator = false playbackState = .stopped playerButtonPlaybackState = .stopped setupPlaybackStateSubscription() @@ -79,7 +80,6 @@ class AudioPlayerState: ObservableObject, Identifiable { func updateState(progress: Double) async { let progress = max(0.0, min(progress, 1.0)) self.progress = progress - showProgressIndicator = true if let audioPlayer { var shouldResumeProgressPublishing = false if audioPlayer.state == .playing { @@ -108,7 +108,6 @@ class AudioPlayerState: ObservableObject, Identifiable { audioPlayerSubscription = nil audioPlayer = nil playbackState = .stopped - showProgressIndicator = false } func reportError(_ error: Error) { @@ -143,13 +142,11 @@ class AudioPlayerState: ObservableObject, Identifiable { } startPublishProgress() playbackState = .playing - showProgressIndicator = true case .didPausePlaying, .didStopPlaying, .didFinishPlaying: stopPublishProgress() playbackState = .stopped if case .didFinishPlaying = action { progress = 0.0 - showProgressIndicator = false } case .didFailWithError: stopPublishProgress() diff --git a/UnitTests/Sources/AudioPlayerStateTests.swift b/UnitTests/Sources/AudioPlayerStateTests.swift index 57e60d517..3554ae795 100644 --- a/UnitTests/Sources/AudioPlayerStateTests.swift +++ b/UnitTests/Sources/AudioPlayerStateTests.swift @@ -285,7 +285,7 @@ class AudioPlayerStateTests: XCTestCase { } audioPlayerActionsSubject.send(.didStartPlaying) try await deferredPlayingState.fulfill() - XCTAssertTrue(audioPlayerState.showProgressIndicator) + XCTAssertFalse(audioPlayerState.showProgressIndicator) let deferred = deferFulfillment(audioPlayerState.$playbackState) { action in switch action { @@ -300,6 +300,6 @@ class AudioPlayerStateTests: XCTestCase { try await deferred.fulfill() XCTAssertEqual(audioPlayerState.playbackState, .error) XCTAssertFalse(audioPlayerState.isPublishingProgress) - XCTAssertTrue(audioPlayerState.showProgressIndicator) + XCTAssertFalse(audioPlayerState.showProgressIndicator) } } diff --git a/UnitTests/__Snapshots__/PreviewTests/test_voiceMessagePreviewComposer.1.png b/UnitTests/__Snapshots__/PreviewTests/test_voiceMessagePreviewComposer.1.png index d898961d8..422bb9daa 100644 --- a/UnitTests/__Snapshots__/PreviewTests/test_voiceMessagePreviewComposer.1.png +++ b/UnitTests/__Snapshots__/PreviewTests/test_voiceMessagePreviewComposer.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e47226f5fbdd1032534b2f6a1a715d9eee94b25e5ec7e02592b7c51c10a33f70 -size 61828 +oid sha256:645fc597d30595973832dc7adb5ef5fd6cb20e59d21d6ecebc5812f0622ed9ec +size 61821 diff --git a/UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomPlaybackView.1.png b/UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomPlaybackView.1.png index 9e10dc2eb..203e8435b 100644 --- a/UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomPlaybackView.1.png +++ b/UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomPlaybackView.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:be68924b6f15ba61c3e9e18a942c724df55f6656146a3f933a74f2f0880568bf -size 61158 +oid sha256:3b90a9dd7a0d6a516843258eef338b50004d28e7533317533e4fcd15c4e44b7e +size 61969 diff --git a/UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomTimelineView.Bubble.png b/UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomTimelineView.Bubble.png index edd40461d..cff73d2ab 100644 --- a/UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomTimelineView.Bubble.png +++ b/UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomTimelineView.Bubble.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c9bbb2a5218b2055e27ed7ab7770acd0e8e26973505bd28f979cfc43bffd0a64 -size 71007 +oid sha256:93e0061262bfa46b6d69a4546e65776b1165dc94110c2b77d6190115e935c1eb +size 71420 diff --git a/UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomTimelineView.Plain.png b/UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomTimelineView.Plain.png index 1d96f79d1..5ee59550b 100644 --- a/UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomTimelineView.Plain.png +++ b/UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomTimelineView.Plain.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:60cce5e7f560c36f75ae5737736ab539be31bbf094172aae9d9034f3f4fb4786 -size 67320 +oid sha256:1e430f4465a8963c397f2bb3eb0a43487ba203a2190b3144a5202c920a658730 +size 67743 diff --git a/changelog.d/2190.feature b/changelog.d/2190.feature new file mode 100644 index 000000000..a62d18e95 --- /dev/null +++ b/changelog.d/2190.feature @@ -0,0 +1 @@ +The voice message playback position indicator is displayed during playback or pause.