Emergency 20 Dokumentation  4.2.0
VideoPlayerWindow.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
15 #include <qsf/gui/GuiDocument.h>
17 
18 
19 //[-------------------------------------------------------]
20 //[ Forward declarations ]
21 //[-------------------------------------------------------]
22 namespace Rocket
23 {
24  namespace Core
25  {
26  class ElementText;
27  }
28 }
29 namespace qsf
30 {
31  class AudioMixer;
32  class VideoPlayer;
33  class JobArguments;
34 }
35 
36 
37 //[-------------------------------------------------------]
38 //[ Namespace ]
39 //[-------------------------------------------------------]
40 namespace em5
41 {
42 
43 
44  //[-------------------------------------------------------]
45  //[ Classes ]
46  //[-------------------------------------------------------]
48  {
49 
50 
51  //[-------------------------------------------------------]
52  //[ Public methods ]
53  //[-------------------------------------------------------]
54  public:
55  explicit VideoPlayerWindow(qsf::GuiContext& guiContext);
56  virtual ~VideoPlayerWindow();
57 
67  void showVideoByFilename(const std::string& videoFile, bool exclusiveMode = true);
68 
69  bool isVideoPlaying() const;
70  qsf::VideoPlayer& getVideoPlayer() const;
71 
72 
73  //[-------------------------------------------------------]
74  //[ Public virtual qsf::GuiDocument methods ]
75  //[-------------------------------------------------------]
76  public:
77  virtual void processEvent(const std::string& eventKey, Rocket::Core::Event& event) override;
78  virtual void processViewportDimensionsChanged(int width, int height) override;
79 
80 
81  //[-------------------------------------------------------]
82  //[ Private virtual qsf::GuiDocument methods ]
83  //[-------------------------------------------------------]
84  private:
85  virtual bool onPreShow() override;
86  virtual void onPreHide() override;
87 
88 
89  //[-------------------------------------------------------]
90  //[ Private methods ]
91  //[-------------------------------------------------------]
92  private:
93  void setupGui();
94  void onReloadGui();
95  void clearVideo();
96  void setupVideoImageElement(bool onlyPositionAndSize);
97  void updateVideoTextureReference();
98  void onPlaybackFinished();
99  void onSyncVideo(const qsf::JobArguments& jobArguments);
100  void disableJobManagerAutoupdate(const qsf::StringHash& providerJobManagerId);
101  void updatePlayPauseButton();
102  void updateProgressTime();
103  void loadSubtitles();
104  void clearSubtitles();
105  void updateSubtitles();
106 
107 
108  //[-------------------------------------------------------]
109  //[ Private definitions ]
110  //[-------------------------------------------------------]
111  private:
112  struct Subtitle
113  {
114  qsf::Time startTime;
115  qsf::Time endTime;
116  std::string text;
117 
118  Subtitle(qsf::Time _startTime, qsf::Time _endTime, const std::string& _text) :
119  startTime(_startTime),
120  endTime(_endTime),
121  text(_text)
122  {
123  // Nothing here
124  }
125  };
126  typedef std::vector<Subtitle> Subtitles;
127 
128 
129  //[-------------------------------------------------------]
130  //[ Private data ]
131  //[-------------------------------------------------------]
132  private:
133  qsf::AudioMixer& mAudioMixer;
134  std::unique_ptr<qsf::VideoPlayer> mVideoPlayer;
135  bool mVideoPlaybackInProgress;
136  qsf::Time mTotalVideoDuration;
137  float mPreviousFpsLimitation;
138  glm::ivec2 mScreenSize;
139  std::vector<qsf::StringHash> mDisabledJobManagerAutoupdate;
140  qsf::WeakPtr<qsf::CameraComponent> mPreviousMainCamera;
141  std::string mCurrentVideoFileName;
142  Subtitles mSubtitles;
143  uint32 mCurrentSubtitleIndex;
144  bool mPreviousShowVideoSubtitles;
145  bool mVolumeSliderShown;
146  Rocket::Core::Element* mVideoElement;
147  Rocket::Core::Element* mVideoImageElement;
148  Rocket::Core::ElementText* mProgressTimeTextElement;
149  Rocket::Core::Element* mSubtitleElement;
150 
151 
152  };
153 
154 
155 //[-------------------------------------------------------]
156 //[ Namespace ]
157 //[-------------------------------------------------------]
158 } // em5
Definition: ActionPriority.h:13
Definition: VideoPlayerWindow.h:47
unsigned int uint32
Definition: PlatformTypes.h:181
Graphical User Interface (GUI) document base class.
Definition: GuiDocument.h:51
#define EM5_API_EXPORT
Definition: Export.h:28
Audio mixer class.
Definition: AudioMixer.h:55
Definition: OverlayComponent.h:29
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
Definition: PickupPersonByParamedicAction.h:21
Ingame Graphical User Interface (GUI) context class.
Definition: GuiContext.h:62
Self-contained video player.
Definition: VideoPlayer.h:55
Compile time string hash class.
Definition: StringHash.h:59
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32