forked from teamnwah/openmw-tes3coop
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.4 KiB
C++
84 lines
2.4 KiB
C++
10 years ago
|
#ifndef VIDEOPLAYER_H
|
||
|
#define VIDEOPLAYER_H
|
||
|
|
||
|
#include <string>
|
||
|
#include <memory>
|
||
|
|
||
10 years ago
|
#include <iosfwd>
|
||
|
|
||
|
#include <osg/Texture2D>
|
||
|
|
||
|
#include <boost/shared_ptr.hpp>
|
||
|
|
||
|
namespace osg
|
||
|
{
|
||
|
class Texture2D;
|
||
|
}
|
||
|
|
||
10 years ago
|
namespace Video
|
||
|
{
|
||
|
|
||
|
struct VideoState;
|
||
|
class MovieAudioFactory;
|
||
|
|
||
|
/**
|
||
10 years ago
|
* @brief Plays a video on an osg texture.
|
||
10 years ago
|
*/
|
||
|
class VideoPlayer
|
||
|
{
|
||
|
public:
|
||
|
VideoPlayer();
|
||
|
~VideoPlayer();
|
||
|
|
||
10 years ago
|
/// @brief Set the MovieAudioFactory to use.
|
||
|
/// @par This class must be implemented by the user and is responsible for reading the decoded audio data.
|
||
|
/// @note If you do not set up a MovieAudioFactory, then audio streams will be ignored and the video will be played with no sound.
|
||
10 years ago
|
/// @note Takes ownership of the passed pointer.
|
||
|
void setAudioFactory (MovieAudioFactory* factory);
|
||
|
|
||
|
/// Return true if a video is currently playing and it has an audio stream.
|
||
|
bool hasAudioStream();
|
||
|
|
||
|
/// Play the given video. If a video is already playing, the old video is closed first.
|
||
10 years ago
|
/// @note The video will be unpaused by default. Use the pause() and play() methods to control pausing.
|
||
10 years ago
|
void playVideo (boost::shared_ptr<std::istream> inputstream);
|
||
10 years ago
|
|
||
10 years ago
|
/// Get the current playback time position in the video, in seconds
|
||
|
double getCurrentTime();
|
||
|
|
||
|
/// Get the duration of the video in seconds
|
||
|
double getDuration();
|
||
|
|
||
|
/// Seek to the specified time position in the video
|
||
|
void seek(double time);
|
||
|
|
||
|
void play();
|
||
|
void pause();
|
||
|
bool isPaused();
|
||
|
|
||
10 years ago
|
/// This should be called every frame by the user to update the video texture.
|
||
10 years ago
|
/// @return Returns true if the video is still playing, false if we have reached the end of the video stream.
|
||
|
bool update();
|
||
10 years ago
|
|
||
|
/// Stop the currently playing video, if a video is playing.
|
||
|
void close();
|
||
|
|
||
10 years ago
|
/// Return the texture of the currently playing video, or a null pointer if no video is playing.
|
||
|
osg::ref_ptr<osg::Texture2D> getVideoTexture();
|
||
|
|
||
10 years ago
|
/// Return the width of the currently playing video, or 0 if no video is playing.
|
||
|
int getVideoWidth();
|
||
|
/// Return the height of the currently playing video, or 0 if no video is playing.
|
||
|
int getVideoHeight();
|
||
|
|
||
|
|
||
|
private:
|
||
|
VideoState* mState;
|
||
|
|
||
|
std::auto_ptr<MovieAudioFactory> mAudioFactory;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif
|