mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:27:35 +00:00
SoundPlayer: Update the SoundPlayer interface
Also fix rebase conflict
This commit is contained in:
parent
45e928bfb2
commit
7aa5297835
5 changed files with 395 additions and 59 deletions
|
@ -26,24 +26,28 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Common.h"
|
||||
#include "PlaybackManager.h"
|
||||
#include "Player.h"
|
||||
#include "SampleWidget.h"
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/Label.h>
|
||||
#include <LibGUI/Slider.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibGUI/Window.h>
|
||||
|
||||
class SoundPlayerWidget final : public GUI::Widget {
|
||||
class SoundPlayerWidget final : public GUI::Widget
|
||||
, public Player {
|
||||
C_OBJECT(SoundPlayerWidget)
|
||||
public:
|
||||
virtual ~SoundPlayerWidget() override;
|
||||
void open_file(String path);
|
||||
void open_file(StringView path) override;
|
||||
void hide_scope(bool);
|
||||
PlaybackManager& manager() { return m_manager; }
|
||||
Audio::ClientConnection& client_connection() override { return m_connection; }
|
||||
PlaybackManager& playback_manager() override { return m_manager; }
|
||||
|
||||
private:
|
||||
explicit SoundPlayerWidget(GUI::Window&, NonnullRefPtr<Audio::ClientConnection>);
|
||||
explicit SoundPlayerWidget(GUI::Window& window, Audio::ClientConnection& connection, PlaybackManager& manager);
|
||||
|
||||
virtual void drop_event(GUI::DropEvent&) override;
|
||||
|
||||
|
@ -52,35 +56,10 @@ private:
|
|||
int normalize_rate(int) const;
|
||||
int denormalize_rate(int) const;
|
||||
|
||||
class Slider final : public GUI::Slider {
|
||||
C_OBJECT(Slider)
|
||||
public:
|
||||
virtual ~Slider() override;
|
||||
Function<void(int)> on_knob_released;
|
||||
void set_value(int value)
|
||||
{
|
||||
if (!knob_dragging())
|
||||
GUI::Slider::set_value(value);
|
||||
}
|
||||
|
||||
protected:
|
||||
Slider(Orientation orientation)
|
||||
: GUI::Slider(orientation)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void mouseup_event(GUI::MouseEvent& event) override
|
||||
{
|
||||
if (on_knob_released && is_enabled())
|
||||
on_knob_released(value());
|
||||
|
||||
GUI::Slider::mouseup_event(event);
|
||||
}
|
||||
};
|
||||
|
||||
GUI::Window& m_window;
|
||||
NonnullRefPtr<Audio::ClientConnection> m_connection;
|
||||
PlaybackManager m_manager;
|
||||
Audio::ClientConnection& m_connection;
|
||||
PlaybackManager& m_manager;
|
||||
|
||||
float m_sample_ratio { 1.0 };
|
||||
RefPtr<GUI::Label> m_status;
|
||||
RefPtr<GUI::Label> m_elapsed;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue