mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-01 20:10:28 +00:00
SoundPlayer: Fix glitchy visualization on pause/stop
Previously when pausing or stoping a track in SoundPlayer, the visualizations would glitch out. This was caused by them being updated with the same buffer over and over. With this patch a pause action will freeze the visualization at the point of the pause and a stop action will reset the visualization so it displays nothing until a track is started.
This commit is contained in:
parent
f1d8e55168
commit
e98315de6b
Notes:
sideshowbarker
2024-07-17 09:49:48 +09:00
Author: https://github.com/Alphapork Commit: https://github.com/SerenityOS/serenity/commit/e98315de6b Pull-request: https://github.com/SerenityOS/serenity/pull/18600 Reviewed-by: https://github.com/caoimhebyrne ✅ Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/kleinesfilmroellchen ✅
2 changed files with 6 additions and 1 deletions
|
@ -21,7 +21,8 @@ Player::Player(Audio::ConnectionToServer& audio_client_connection)
|
|||
|
||||
auto played_seconds = samples_played / sample_rate;
|
||||
time_elapsed(played_seconds);
|
||||
sound_buffer_played(m_playback_manager.current_buffer(), m_playback_manager.device_sample_rate(), samples_played);
|
||||
if (play_state() == PlayState::Playing)
|
||||
sound_buffer_played(m_playback_manager.current_buffer(), m_playback_manager.device_sample_rate(), samples_played);
|
||||
};
|
||||
m_playback_manager.on_finished_playing = [&]() {
|
||||
set_play_state(PlayState::Stopped);
|
||||
|
|
|
@ -213,6 +213,10 @@ void SoundPlayerWidgetAdvancedView::play_state_changed(Player::PlayState state)
|
|||
m_stop_action->set_enabled(state != PlayState::Stopped && state != PlayState::NoFileLoaded);
|
||||
|
||||
m_playback_progress_slider->set_enabled(state != PlayState::NoFileLoaded);
|
||||
if (state == PlayState::Stopped) {
|
||||
m_playback_progress_slider->set_value(m_playback_progress_slider->min(), GUI::AllowCallback::No);
|
||||
m_visualization->reset_buffer();
|
||||
}
|
||||
}
|
||||
|
||||
void SoundPlayerWidgetAdvancedView::loop_mode_changed(Player::LoopMode)
|
||||
|
|
Loading…
Reference in a new issue