mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +00:00
VideoPlayer: Start fleshing out the user interface
This adds player widget with working play/pause controls, a seek bar which currently only displays the current playback position, and a button to cycle between the scaling modes. The player uses the new PlaybackManager class to handle demuxing, decoding, and frame presentation timing. Currently, the volume control is non-functional.
This commit is contained in:
parent
353e1c2b4d
commit
f99d356a17
6 changed files with 429 additions and 82 deletions
72
Userland/Applications/VideoPlayer/VideoFrameWidget.h
Normal file
72
Userland/Applications/VideoPlayer/VideoFrameWidget.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Gregory Bertilson <zaggy1024@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/StringView.h>
|
||||
#include <LibGUI/Event.h>
|
||||
#include <LibGUI/Frame.h>
|
||||
|
||||
namespace VideoPlayer {
|
||||
|
||||
enum class VideoSizingMode : u8 {
|
||||
Fit,
|
||||
Fill,
|
||||
Stretch,
|
||||
FullSize,
|
||||
Sentinel
|
||||
};
|
||||
|
||||
class VideoFrameWidget : public GUI::Frame {
|
||||
C_OBJECT(VideoFrameWidget)
|
||||
public:
|
||||
virtual ~VideoFrameWidget() override = default;
|
||||
|
||||
void set_bitmap(Gfx::Bitmap const*);
|
||||
Gfx::Bitmap* bitmap() { return m_bitmap.ptr(); }
|
||||
Gfx::Bitmap const* bitmap() const { return m_bitmap.ptr(); }
|
||||
|
||||
void set_sizing_mode(VideoSizingMode value) { m_sizing_mode = value; }
|
||||
VideoSizingMode sizing_mode() const { return m_sizing_mode; }
|
||||
|
||||
void set_auto_resize(bool value);
|
||||
bool auto_resize() const { return m_auto_resize; }
|
||||
|
||||
Function<void()> on_click;
|
||||
|
||||
protected:
|
||||
explicit VideoFrameWidget();
|
||||
|
||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
|
||||
private:
|
||||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
VideoSizingMode m_sizing_mode { VideoSizingMode::Fit };
|
||||
bool m_auto_resize { false };
|
||||
};
|
||||
|
||||
constexpr StringView video_sizing_mode_name(VideoSizingMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case VideoSizingMode::Fit:
|
||||
return "Fit"sv;
|
||||
break;
|
||||
case VideoSizingMode::Fill:
|
||||
return "Fill"sv;
|
||||
break;
|
||||
case VideoSizingMode::Stretch:
|
||||
return "Stretch"sv;
|
||||
break;
|
||||
case VideoSizingMode::FullSize:
|
||||
return "Full size"sv;
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue