OpenShot Library | libopenshot  0.2.6
QtPlayer.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Header file for QtPlayer class
4  * @author Duzy Chan <code@duzy.info>
5  * @author Jonathan Thomas <jonathan@openshot.org>
6  *
7  * @ref License
8  */
9 
10 /* LICENSE
11  *
12  * Copyright (c) 2008-2019 OpenShot Studios, LLC
13  * <http://www.openshotstudios.com/>. This file is part of
14  * OpenShot Library (libopenshot), an open-source project dedicated to
15  * delivering high quality video editing and animation solutions to the
16  * world. For more information visit <http://www.openshot.org/>.
17  *
18  * OpenShot Library (libopenshot) is free software: you can redistribute it
19  * and/or modify it under the terms of the GNU Lesser General Public License
20  * as published by the Free Software Foundation, either version 3 of the
21  * License, or (at your option) any later version.
22  *
23  * OpenShot Library (libopenshot) is distributed in the hope that it will be
24  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU Lesser General Public License for more details.
27  *
28  * You should have received a copy of the GNU Lesser General Public License
29  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
30  */
31 
32 #ifndef OPENSHOT_QT_PLAYER_H
33 #define OPENSHOT_QT_PLAYER_H
34 
35 #include <iostream>
36 #include <vector>
37 #include "PlayerBase.h"
38 #include "Qt/PlayerPrivate.h"
39 #include "RendererBase.h"
40 
41 namespace openshot
42 {
43  /**
44  * @brief This class is used to playback a video from a reader.
45  *
46  */
48  {
50  bool threads_started;
51 
52  public:
53  /// Default constructor
54  explicit QtPlayer();
55  explicit QtPlayer(openshot::RendererBase *rb);
56 
57  /// Default destructor
58  virtual ~QtPlayer();
59 
60  /// Close audio device
61  void CloseAudioDevice();
62 
63  /// Get Error (if any)
64  std::string GetError();
65 
66  /// Get Audio Devices from JUCE
67  std::vector<openshot::AudioDeviceInfo> GetAudioDeviceNames();
68 
69  /// Play the video
70  void Play();
71 
72  /// Display a loading animation
73  void Loading();
74 
75  /// Get the current mode
77 
78  /// Pause the video
79  void Pause();
80 
81  /// Get the current frame number being played
82  int64_t Position();
83 
84  /// Seek to a specific frame in the player
85  void Seek(int64_t new_frame);
86 
87  /// Set the source URL/path of this player (which will create an internal Reader)
88  void SetSource(const std::string &source);
89 
90  /// Set the QWidget which will be used as the display (note: QLabel works well). This does not take a
91  /// normal pointer, but rather a LONG pointer id (and it re-casts the QWidget pointer inside libopenshot).
92  /// This is required due to SIP and SWIG incompatibility in the Python bindings.
93  void SetQWidget(int64_t qwidget_address);
94 
95  /// Get the Renderer pointer address (for Python to cast back into a QObject)
96  int64_t GetRendererQObject();
97 
98  /// Get the Playback speed
99  float Speed();
100 
101  /// Set the Playback speed (1.0 = normal speed, <1.0 = slower, >1.0 faster)
102  void Speed(float new_speed);
103 
104  /// Stop the video player and clear the cached frames
105  void Stop();
106 
107  /// Set the current reader
108  void Reader(openshot::ReaderBase *new_reader);
109 
110  /// Get the current reader, such as a FFmpegReader
112 
113  /// Get the Volume
114  float Volume();
115 
116  /// Set the Volume (1.0 = normal volume, <1.0 = quieter, >1.0 louder)
117  void Volume(float new_volume);
118  };
119 }
120 
121 #endif
float Speed()
Get the Playback speed.
Definition: QtPlayer.cpp:218
void Loading()
Display a loading animation.
Definition: QtPlayer.cpp:133
This class is used to playback a video from a reader.
Definition: QtPlayer.h:47
float Volume()
Get the Volume.
Definition: QtPlayer.cpp:232
QtPlayer()
Default constructor.
Definition: QtPlayer.cpp:42
openshot::ReaderBase * Reader()
Get the current reader, such as a FFmpegReader.
Definition: QtPlayer.cpp:202
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:97
This is the base class of all Players in libopenshot.
Definition: PlayerBase.h:59
void Pause()
Pause the video.
Definition: QtPlayer.cpp:144
void SetSource(const std::string &source)
Set the source URL/path of this player (which will create an internal Reader)
Definition: QtPlayer.cpp:88
Source file for PlayerPrivate class.
The private part of QtPlayer class, which contains an audio thread and video thread, and controls the video timing and audio synchronization code.
Definition: PlayerPrivate.h:48
std::string GetError()
Get Error (if any)
Definition: QtPlayer.cpp:70
int64_t Position()
Get the current frame number being played.
Definition: QtPlayer.cpp:150
void SetQWidget(int64_t qwidget_address)
Definition: QtPlayer.cpp:207
std::vector< openshot::AudioDeviceInfo > GetAudioDeviceNames()
Get Audio Devices from JUCE.
Definition: QtPlayer.cpp:80
void Play()
Play the video.
Definition: QtPlayer.cpp:120
void Seek(int64_t new_frame)
Seek to a specific frame in the player.
Definition: QtPlayer.cpp:155
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:46
openshot::PlaybackMode Mode()
Get the current mode.
Definition: QtPlayer.cpp:139
Header file for RendererBase class.
Header file for PlayerBase class.
void CloseAudioDevice()
Close audio device.
Definition: QtPlayer.cpp:63
int64_t GetRendererQObject()
Get the Renderer pointer address (for Python to cast back into a QObject)
Definition: QtPlayer.cpp:213
PlaybackMode
This enumeration determines the mode of the video player (i.e. playing, paused, etc...)
Definition: PlayerBase.h:44
This is the base class of all Renderers in libopenshot.
Definition: RendererBase.h:48
void Stop()
Stop the video player and clear the cached frames.
Definition: QtPlayer.cpp:173
virtual ~QtPlayer()
Default destructor.
Definition: QtPlayer.cpp:55