LibMedia: Give PlaybackManager a playback state getter

This commit is contained in:
Zaggy1024 2025-10-02 18:52:47 -05:00 committed by Jelle Raaijmakers
parent 9117f661a8
commit 27ed536540
6 changed files with 35 additions and 0 deletions

View File

@ -228,6 +228,11 @@ bool PlaybackManager::is_playing()
return m_handler->is_playing();
}
PlaybackState PlaybackManager::state()
{
return m_handler->state();
}
void PlaybackManager::set_volume(double volume)
{
if (m_audio_sink)

View File

@ -17,6 +17,7 @@
#include <LibMedia/Export.h>
#include <LibMedia/Forward.h>
#include <LibMedia/PlaybackStates/Forward.h>
#include <LibMedia/PlaybackStates/PlaybackState.h>
#include <LibMedia/Providers/MediaTimeProvider.h>
#include <LibMedia/Track.h>
#include <LibThreading/Mutex.h>
@ -71,6 +72,7 @@ public:
void pause();
bool is_playing();
PlaybackState state();
void set_volume(double);

View File

@ -37,6 +37,10 @@ public:
{
return false;
}
virtual PlaybackState state() override
{
return PlaybackState::Paused;
}
};
}

View File

@ -0,0 +1,18 @@
/*
* Copyright (c) 2025, Gregory Bertilson <gregory@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
namespace Media {
enum class PlaybackState : u8 {
Playing,
Paused,
};
}

View File

@ -7,6 +7,7 @@
#pragma once
#include <LibMedia/Forward.h>
#include <LibMedia/PlaybackStates/PlaybackState.h>
namespace Media {
@ -25,6 +26,7 @@ public:
virtual void pause() = 0;
virtual bool is_playing() = 0;
virtual PlaybackState state() = 0;
protected:
PlaybackManager& manager() const { return m_manager; }

View File

@ -39,6 +39,10 @@ public:
{
return true;
}
virtual PlaybackState state() override
{
return PlaybackState::Playing;
}
};
}