ladybird/Libraries/LibMedia/PlaybackStates/PlaybackStateHandler.h
Zaggy1024 5a120bff33 LibMedia: Use a combined status to exit the seeking/buffering states
Instead of tracking in-flight seeks across all the sinks in the seeking
state handler, move the logic to PlaybackManager to determine the
overall status and then notify the state of that status to potentially
trigger resumption.

The buffering state handler can then share essentially the same logic
instead of having the playback manager specifically track the blocked
tracks for it.
2026-06-11 05:49:14 -05:00

49 lines
1.1 KiB
C++

/*
* Copyright (c) 2025-2026, Gregory Bertilson <gregory@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Time.h>
#include <LibMedia/Forward.h>
#include <LibMedia/PipelineStatus.h>
#include <LibMedia/PlaybackStates/AvailableData.h>
#include <LibMedia/PlaybackStates/PlaybackState.h>
#include <LibMedia/SeekMode.h>
namespace Media {
class PlaybackStateHandler {
public:
PlaybackStateHandler(PlaybackManager& manager)
: m_manager(manager)
{
}
virtual ~PlaybackStateHandler() = default;
virtual void on_enter() = 0;
virtual void on_exit() = 0;
virtual AK::Duration current_time() const;
virtual void start() { }
virtual void play() = 0;
virtual void pause() = 0;
virtual void seek(AK::Duration timestamp, SeekMode);
virtual bool is_playing() = 0;
virtual PlaybackState state() = 0;
virtual AvailableData available_data() = 0;
virtual void on_pipeline_status_changed(PipelineStatus);
protected:
PlaybackManager& manager() const { return m_manager; }
private:
PlaybackManager& m_manager;
};
}