1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:17:46 +00:00

SoundPlayer: Fix inconsistencies and code duplication

This is a first pass at refactoring SoundPlayer so that the View widget
is decoupled from the player itself.

In doing so, this fixed a couple of issues, including possibly
inconsistent states (e.g. player could be paused and stopped at the
same time).

With the change, Player actually controls the show, and calls methods
overriden by its subclasses to perform actions, such as update the Seek
bar; the hard work of massaging the raw data is done by the Player
class, so subclasses don't need to reimplement any of these things.

This also removes some copies of playlist management code that happened
to be copied+pasted inside callbacks of buttons -- it now lives inside
a neatly packaged Playlist class, and the Player only asks for the next
song to play.

In addition, the menu bar has been slightly rearranged.
This commit is contained in:
Leandro Pereira 2021-09-29 21:55:42 -07:00 committed by Andreas Kling
parent 73924f9416
commit 3126b78903
14 changed files with 447 additions and 304 deletions

View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2021, Cesar Torres <shortanemoia@protonmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibAudio/Buffer.h>
#include <LibGUI/Frame.h>
class VisualizationWidget : public GUI::Frame {
C_OBJECT(VisualizationWidget)
public:
virtual void set_buffer(RefPtr<Audio::Buffer> buffer) = 0;
virtual void set_samplerate(int) { }
protected:
virtual ~VisualizationWidget() = default;
};