OpenShot Library | libopenshot  0.2.7
PlayerBase.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Header file for PlayerBase class
4  * @author Jonathan Thomas <jonathan@openshot.org>
5  *
6  * @ref License
7  */
8 
9 /* LICENSE
10  *
11  * Copyright (c) 2008-2019 OpenShot Studios, LLC
12  * <http://www.openshotstudios.com/>. This file is part of
13  * OpenShot Library (libopenshot), an open-source project dedicated to
14  * delivering high quality video editing and animation solutions to the
15  * world. For more information visit <http://www.openshot.org/>.
16  *
17  * OpenShot Library (libopenshot) is free software: you can redistribute it
18  * and/or modify it under the terms of the GNU Lesser General Public License
19  * as published by the Free Software Foundation, either version 3 of the
20  * License, or (at your option) any later version.
21  *
22  * OpenShot Library (libopenshot) is distributed in the hope that it will be
23  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU Lesser General Public License for more details.
26  *
27  * You should have received a copy of the GNU Lesser General Public License
28  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
29  */
30 
31 #ifndef OPENSHOT_PLAYER_BASE_H
32 #define OPENSHOT_PLAYER_BASE_H
33 
34 #include <iostream>
35 #include "ReaderBase.h"
36 
37 namespace openshot
38 {
39  /**
40  * @brief This enumeration determines the mode of the video player (i.e. playing, paused, etc...)
41  *
42  * A player can be in one of the following modes, which controls how it behaves.
43  */
45  {
46  PLAYBACK_PLAY, ///< Play the video normally
47  PLAYBACK_PAUSED, ///< Pause the video (holding the last displayed frame)
48  PLAYBACK_LOADING, ///< Loading the video (display a loading animation)
49  PLAYBACK_STOPPED, ///< Stop playing the video (clear cache, done with player)
50  };
51 
52  /**
53  * @brief This is the base class of all Players in libopenshot.
54  *
55  * Players are responsible for displaying images and playing back audio samples with specific
56  * frame rates and sample rates. All Players must be based on this class, and include these
57  * methods.
58  */
59  class PlayerBase
60  {
61  protected:
62  float speed;
63  float volume;
66 
67  public:
68 
69  /// Display a loading animation
70  virtual void Loading() = 0;
71 
72  /// Get the current mode
73  virtual PlaybackMode Mode() = 0;
74 
75  /// Play the video
76  virtual void Play() = 0;
77 
78  /// Pause the video
79  virtual void Pause() = 0;
80 
81  /// Get the current frame number being played
82  virtual int64_t Position() = 0;
83 
84  /// Seek to a specific frame in the player
85  virtual void Seek(int64_t new_frame) = 0;
86 
87  /// Get the Playback speed
88  virtual float Speed() = 0;
89 
90  /// Set the Playback speed (1.0 = normal speed, <1.0 = slower, >1.0 faster)
91  virtual void Speed(float new_speed) = 0;
92 
93  /// Stop the video player and clear the cached frames
94  virtual void Stop() = 0;
95 
96  /// Get the current reader, such as a FFmpegReader
97  virtual openshot::ReaderBase* Reader() = 0;
98 
99  /// Set the current reader, such as a FFmpegReader
100  virtual void Reader(openshot::ReaderBase *new_reader) = 0;
101 
102  /// Get the Volume
103  virtual float Volume() = 0;
104 
105  /// Set the Volume (1.0 = normal volume, <1.0 = quieter, >1.0 louder)
106  virtual void Volume(float new_volume) = 0;
107 
108  virtual ~PlayerBase() = default;
109  };
110 
111 }
112 
113 #endif
virtual void Seek(int64_t new_frame)=0
Seek to a specific frame in the player.
virtual void Play()=0
Play the video.
Definition: PlayerBase.cpp:41
Header file for ReaderBase class.
Loading the video (display a loading animation)
Definition: PlayerBase.h:48
Stop playing the video (clear cache, done with player)
Definition: PlayerBase.h:49
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:97
virtual void Pause()=0
Pause the video.
Definition: PlayerBase.cpp:46
virtual void Loading()=0
Display a loading animation.
Definition: PlayerBase.cpp:36
This is the base class of all Players in libopenshot.
Definition: PlayerBase.h:59
openshot::ReaderBase * reader
Definition: PlayerBase.h:64
virtual PlaybackMode Mode()=0
Get the current mode.
Pause the video (holding the last displayed frame)
Definition: PlayerBase.h:47
virtual float Volume()=0
Get the Volume.
Definition: PlayerBase.cpp:76
virtual openshot::ReaderBase * Reader()=0
Get the current reader, such as a FFmpegReader.
Definition: PlayerBase.cpp:66
virtual float Speed()=0
Get the Playback speed.
Definition: PlayerBase.cpp:51
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:46
PlaybackMode
This enumeration determines the mode of the video player (i.e. playing, paused, etc...)
Definition: PlayerBase.h:44
virtual void Stop()=0
Stop the video player and clear the cached frames.
Definition: PlayerBase.cpp:61
virtual int64_t Position()=0
Get the current frame number being played.
virtual ~PlayerBase()=default
Play the video normally.
Definition: PlayerBase.h:46
PlaybackMode mode
Definition: PlayerBase.h:65