Movie.hpp
1 
2 /*
3  * Movie.hpp
4  * sfeMovie project
5  *
6  * Copyright (C) 2010-2015 Lucas Soltic
7  * lucas.soltic@orange.fr
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 
26 #ifndef SFEMOVIE_MOVIE_HPP
27 #define SFEMOVIE_MOVIE_HPP
28 
29 #include <SFML/Graphics.hpp>
30 #include <SFML/System.hpp>
31 #include <sfeMovie/Visibility.hpp>
32 #include <sfeMovie/StreamSelection.hpp>
33 #include <vector>
34 #include <string>
35 #include <memory>
36 
37 namespace sfe
38 {
41  enum Status
42  {
43  Stopped,
44  Paused,
45  Playing,
46  End
47  };
48 
49  class MovieImpl;
52  class SFE_API Movie : public sf::Drawable, public sf::Transformable
53  {
54  public:
55  Movie();
56  ~Movie();
57 
67  bool openFromFile(const std::string& filename);
68 
73  const Streams& getStreams(MediaType type) const;
74 
88  bool selectStream(const StreamDescriptor& streamDescriptor);
89 
97  void play();
98 
104  void pause();
105 
111  void stop();
112 
115  void update();
116 
121  void setVolume(float volume);
122 
127  float getVolume() const;
128 
133  sf::Time getDuration() const;
134 
139  sf::Vector2f getSize() const;
140 
143  void fit(float x, float y, float width, float height, bool preserveRatio = true);
144 
156  void fit(sf::FloatRect frame, bool preserveRatio = true);
157 
164  float getFramerate() const;
165 
170  unsigned int getSampleRate() const;
171 
176  unsigned int getChannelCount() const;
177 
182  Status getStatus() const;
183 
188  sf::Time getPlayingOffset() const;
189 
196  bool setPlayingOffset(const sf::Time& targetSeekTime);
197 
208  const sf::Texture& getCurrentImage() const;
209  private:
210  void draw(sf::RenderTarget& Target, sf::RenderStates states) const;
211  std::shared_ptr<MovieImpl> m_impl;
212  };
213 } // namespace sfe
214 
215 #endif