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.
51 lines
1 KiB
C++
51 lines
1 KiB
C++
/*
|
|
* Copyright (c) 2026-present, the Ladybird developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibMedia/PlaybackManager.h>
|
|
|
|
namespace Media {
|
|
|
|
class EndedStateHandler final : public PlaybackStateHandler {
|
|
public:
|
|
EndedStateHandler(PlaybackManager& manager)
|
|
: PlaybackStateHandler(manager)
|
|
{
|
|
}
|
|
virtual ~EndedStateHandler() override = default;
|
|
|
|
virtual void on_enter() override
|
|
{
|
|
manager().m_time_provider->pause();
|
|
}
|
|
virtual void on_exit() override { }
|
|
|
|
virtual AK::Duration current_time() const override
|
|
{
|
|
return manager().duration();
|
|
}
|
|
|
|
virtual void play() override { }
|
|
virtual void pause() override { }
|
|
|
|
virtual bool is_playing() override
|
|
{
|
|
return false;
|
|
}
|
|
virtual PlaybackState state() override
|
|
{
|
|
return PlaybackState::Ended;
|
|
}
|
|
virtual AvailableData available_data() override
|
|
{
|
|
return AvailableData::Current;
|
|
}
|
|
|
|
virtual void on_pipeline_status_changed(PipelineStatus) override { }
|
|
};
|
|
|
|
}
|