2017-10-31 17:12:50 +00:00
|
|
|
#pragma once
|
|
|
|
#ifndef ES_CORE_COMPONENTS_VIDEO_COMPONENT_H
|
|
|
|
#define ES_CORE_COMPONENTS_VIDEO_COMPONENT_H
|
2016-12-04 23:47:34 +00:00
|
|
|
|
|
|
|
#include "platform.h"
|
|
|
|
#include GLHEADER
|
|
|
|
|
|
|
|
#include "GuiComponent.h"
|
|
|
|
#include "ImageComponent.h"
|
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
|
|
|
#include <SDL.h>
|
|
|
|
#include <SDL_mutex.h>
|
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
|
2017-06-01 20:08:44 +00:00
|
|
|
std::string getTitlePath();
|
|
|
|
std::string getTitleFolder();
|
|
|
|
void writeSubtitle(const char* gameName, const char* systemName, bool always);
|
|
|
|
|
2016-12-04 23:47:34 +00:00
|
|
|
class VideoComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
// Structure that groups together the configuration of the video component
|
|
|
|
struct Configuration
|
|
|
|
{
|
|
|
|
unsigned startDelay;
|
|
|
|
bool showSnapshotNoVideo;
|
|
|
|
bool showSnapshotDelay;
|
|
|
|
std::string defaultVideoPath;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
VideoComponent(Window* window);
|
|
|
|
virtual ~VideoComponent();
|
|
|
|
|
|
|
|
// Loads the video at the given filepath
|
|
|
|
bool setVideo(std::string path);
|
|
|
|
// Loads a static image that is displayed if the video cannot be played
|
|
|
|
void setImage(std::string path);
|
|
|
|
|
|
|
|
// Configures the component to show the default video
|
|
|
|
void setDefaultVideo();
|
2017-01-25 15:00:56 +00:00
|
|
|
|
2017-06-01 20:08:44 +00:00
|
|
|
// sets whether it's going to render in screensaver mode
|
|
|
|
void setScreensaverMode(bool isScreensaver);
|
|
|
|
|
2016-12-04 23:47:34 +00:00
|
|
|
virtual void onShow() override;
|
|
|
|
virtual void onHide() override;
|
2017-01-25 15:00:56 +00:00
|
|
|
virtual void onScreenSaverActivate() override;
|
|
|
|
virtual void onScreenSaverDeactivate() override;
|
|
|
|
virtual void topWindow(bool isTop) override;
|
2016-12-04 23:47:34 +00:00
|
|
|
|
2017-07-17 03:10:29 +00:00
|
|
|
void onOriginChanged() override;
|
2016-12-04 23:47:34 +00:00
|
|
|
void onSizeChanged() override;
|
|
|
|
void setOpacity(unsigned char opacity) override;
|
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
void render(const Transform4x4f& parentTrans) override;
|
|
|
|
void renderSnapshot(const Transform4x4f& parentTrans);
|
2016-12-04 23:47:34 +00:00
|
|
|
|
|
|
|
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view, const std::string& element, unsigned int properties) override;
|
|
|
|
|
|
|
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
|
|
|
|
|
|
|
virtual void update(int deltaTime);
|
|
|
|
|
2017-03-25 17:02:28 +00:00
|
|
|
// Resize the video to fit this size. If one axis is zero, scale that axis to maintain aspect ratio.
|
|
|
|
// If both are non-zero, potentially break the aspect ratio. If both are zero, no resizing.
|
|
|
|
// Can be set before or after a video is loaded.
|
|
|
|
// setMaxSize() and setResize() are mutually exclusive.
|
|
|
|
virtual void setResize(float width, float height) = 0;
|
2017-10-28 20:24:35 +00:00
|
|
|
inline void setResize(const Vector2f& size) { setResize(size.x(), size.y()); }
|
2017-03-25 17:02:28 +00:00
|
|
|
|
|
|
|
// Resize the video to be as large as possible but fit within a box of this size.
|
|
|
|
// Can be set before or after a video is loaded.
|
|
|
|
// Never breaks the aspect ratio. setMaxSize() and setResize() are mutually exclusive.
|
|
|
|
virtual void setMaxSize(float width, float height) = 0;
|
2017-10-28 20:24:35 +00:00
|
|
|
inline void setMaxSize(const Vector2f& size) { setMaxSize(size.x(), size.y()); }
|
2017-03-25 17:02:28 +00:00
|
|
|
|
2016-12-04 23:47:34 +00:00
|
|
|
private:
|
|
|
|
// Start the video Immediately
|
2017-01-25 15:00:56 +00:00
|
|
|
virtual void startVideo() = 0;
|
2016-12-04 23:47:34 +00:00
|
|
|
// Stop the video
|
2017-01-25 15:00:56 +00:00
|
|
|
virtual void stopVideo() { };
|
|
|
|
// Handle looping the video. Must be called periodically
|
|
|
|
virtual void handleLooping();
|
2016-12-04 23:47:34 +00:00
|
|
|
|
2017-01-25 15:00:56 +00:00
|
|
|
// Start the video after any configured delay
|
|
|
|
void startVideoWithDelay();
|
2016-12-04 23:47:34 +00:00
|
|
|
|
|
|
|
// Handle any delay to the start of playing the video clip. Must be called periodically
|
|
|
|
void handleStartDelay();
|
|
|
|
|
|
|
|
// Manage the playing state of the component
|
|
|
|
void manageState();
|
|
|
|
|
2017-01-25 15:00:56 +00:00
|
|
|
protected:
|
2016-12-04 23:47:34 +00:00
|
|
|
unsigned mVideoWidth;
|
|
|
|
unsigned mVideoHeight;
|
2017-10-28 20:24:35 +00:00
|
|
|
Vector2f mTargetSize;
|
2016-12-04 23:47:34 +00:00
|
|
|
std::shared_ptr<TextureResource> mTexture;
|
|
|
|
float mFadeIn;
|
|
|
|
std::string mStaticImagePath;
|
|
|
|
ImageComponent mStaticImage;
|
|
|
|
|
|
|
|
boost::filesystem::path mVideoPath;
|
|
|
|
boost::filesystem::path mPlayingVideoPath;
|
|
|
|
bool mStartDelayed;
|
|
|
|
unsigned mStartTime;
|
|
|
|
bool mIsPlaying;
|
|
|
|
bool mShowing;
|
2017-01-25 15:00:56 +00:00
|
|
|
bool mDisable;
|
|
|
|
bool mScreensaverActive;
|
2017-06-01 20:08:44 +00:00
|
|
|
bool mScreensaverMode;
|
2017-02-24 01:42:35 +00:00
|
|
|
bool mTargetIsMax;
|
2016-12-04 23:47:34 +00:00
|
|
|
|
|
|
|
Configuration mConfig;
|
|
|
|
};
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#endif // ES_CORE_COMPONENTS_VIDEO_COMPONENT_H
|