mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
This implementation allows: - Accurate seeking to an exact timestamp - Seeking to the keyframe before a timestamp - Seeking to the keyframe after a timestamp These three options will be used to satisfy the playback position selection in the media element's seeking steps.
47 lines
897 B
C++
47 lines
897 B
C++
/*
|
|
* Copyright (c) 2025, Gregory Bertilson <gregory@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Format.h>
|
|
#include <AK/StringView.h>
|
|
#include <AK/Types.h>
|
|
|
|
namespace Media {
|
|
|
|
enum class SeekMode : u8 {
|
|
Accurate,
|
|
FastBefore,
|
|
FastAfter,
|
|
};
|
|
|
|
constexpr StringView seek_mode_to_string(SeekMode seek_mode)
|
|
{
|
|
switch (seek_mode) {
|
|
case SeekMode::Accurate:
|
|
return "Accurate"sv;
|
|
case SeekMode::FastBefore:
|
|
return "FastBefore"sv;
|
|
case SeekMode::FastAfter:
|
|
return "FastAfter"sv;
|
|
}
|
|
VERIFY_NOT_REACHED();
|
|
}
|
|
|
|
}
|
|
|
|
namespace AK {
|
|
|
|
template<>
|
|
struct Formatter<Media::SeekMode> final : Formatter<StringView> {
|
|
ErrorOr<void> format(FormatBuilder& builder, Media::SeekMode color_primaries)
|
|
{
|
|
return Formatter<StringView>::format(builder, Media::seek_mode_to_string(color_primaries));
|
|
}
|
|
};
|
|
|
|
}
|