ladybird/Libraries/LibMedia/PlaybackStates/PlayingStateHandler.cpp
Zaggy1024 9e2a820884 LibMedia+LibWeb: End media element playback based on the pipeline EOS
Instead of comparing the current time to the duration, the playback
manager now has an explicit Ended state that jumps to the duration. The
element simply reacts to that to trigger the ended event and attribute,
along with all the other steps involved.

This moves the ended event to fire after the seeked event, which
matches other browsers' behavior. The spec doesn't explicitly say which
order they should fire in.
2026-06-11 05:49:14 -05:00

32 lines
811 B
C++

/*
* Copyright (c) 2025-2026, Gregory Bertilson <gregory@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "PlayingStateHandler.h"
#include <LibMedia/PlaybackManager.h>
#include <LibMedia/PlaybackStates/BufferingStateHandler.h>
#include <LibMedia/PlaybackStates/EndedStateHandler.h>
#include <LibMedia/PlaybackStates/PausedStateHandler.h>
namespace Media {
void PlayingStateHandler::pause()
{
manager().replace_state_handler<PausedStateHandler>();
}
void PlayingStateHandler::on_pipeline_status_changed(PipelineStatus status)
{
if (status == PipelineStatus::Blocked) {
manager().replace_state_handler<BufferingStateHandler>(true);
return;
}
if (status == PipelineStatus::EndOfStream)
manager().replace_state_handler<EndedStateHandler>();
}
}