1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00
vcmi/client/widgets/VideoWidget.h

68 lines
1.6 KiB
C++
Raw Normal View History

/*
* VideoWidget.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "../gui/CIntObject.h"
#include "../lib/filesystem/ResourcePath.h"
class IVideoInstance;
2024-05-15 18:34:23 +02:00
class VideoWidgetBase : public CIntObject
{
std::unique_ptr<IVideoInstance> videoInstance;
2024-05-15 18:34:23 +02:00
std::pair<std::unique_ptr<ui8[]>, si64> audioData = {nullptr, 0};
int audioHandle = -1;
bool playAudio = false;
2024-05-15 18:34:23 +02:00
void loadAudio(const VideoPath & file);
void startAudio();
void stopAudio();
protected:
VideoWidgetBase(const Point & position, const VideoPath & video, bool playAudio);
virtual void onPlaybackFinished() = 0;
void playVideo(const VideoPath & video);
public:
2024-05-15 18:34:23 +02:00
~VideoWidgetBase();
void activate() override;
void deactivate() override;
void show(Canvas & to) override;
void showAll(Canvas & to) override;
void tick(uint32_t msPassed) override;
2024-05-15 18:34:23 +02:00
2024-09-12 22:28:45 +02:00
Point size();
2024-05-15 18:34:23 +02:00
void setPlaybackFinishedCallback(std::function<void()>);
};
class VideoWidget final: public VideoWidgetBase
{
VideoPath loopedVideo;
void onPlaybackFinished() final;
public:
VideoWidget(const Point & position, const VideoPath & prologue, const VideoPath & looped, bool playAudio);
VideoWidget(const Point & position, const VideoPath & looped, bool playAudio);
};
class VideoWidgetOnce final: public VideoWidgetBase
{
std::function<void()> callback;
void onPlaybackFinished() final;
public:
VideoWidgetOnce(const Point & position, const VideoPath & video, bool playAudio, const std::function<void()> & callback);
};