1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-10-18 13:52:27 +00:00
serenity/Userland/Applications/VideoPlayer/main.cpp
Zaggy1024 f99d356a17 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.
2022-10-31 14:47:13 +01:00

46 lines
1.5 KiB
C++

/*
* Copyright (c) 2021, Hunter Salyer <thefalsehonesty@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "LibVideo/Color/CodingIndependentCodePoints.h"
#include "LibVideo/MatroskaDemuxer.h"
#include <LibCore/ArgsParser.h>
#include <LibGUI/Application.h>
#include <LibGUI/FilePicker.h>
#include <LibGUI/Menu.h>
#include <LibGUI/Window.h>
#include <LibMain/Main.h>
#include <LibVideo/PlaybackManager.h>
#include "VideoPlayerWidget.h"
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
StringView filename = ""sv;
Core::ArgsParser args_parser;
args_parser.add_positional_argument(filename, "The video file to display.", "filename", Core::ArgsParser::Required::No);
args_parser.parse(arguments);
auto app = TRY(GUI::Application::try_create(arguments));
auto window = TRY(GUI::Window::try_create());
window->set_title("Video Player");
window->resize(640, 480);
window->set_resizable(true);
auto main_widget = TRY(window->try_set_main_widget<VideoPlayer::VideoPlayerWidget>(window));
if (!filename.is_empty())
main_widget->open_file(filename);
auto file_menu = TRY(window->try_add_menu("&File"));
TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) {
Optional<String> path = GUI::FilePicker::get_open_filepath(window, "Open video file...");
if (path.has_value())
main_widget->open_file(path.value());
})));
window->show();
return app->exec();
}