sfe::Movie Class Reference

#include <Movie.hpp>

Public Member Functions

bool openFromFile (const std::string &filename)
 Attemps to open a media file (movie or audio)
const Streams & getStreams (MediaType type) const
 Return a description of all the streams of the given type contained in the opened media.
bool selectStream (const StreamDescriptor &streamDescriptor)
 Request activation of the given stream.
void play ()
 Start or resume playing the media playback.
void pause ()
 Pauses the media playback.
void stop ()
 Stops the media playback. The playing offset is reset to the beginning.
void update ()
 Update the media status and eventually decode frames.
void setVolume (float volume)
 Sets the sound's volume (default is 100)
float getVolume () const
 Returns the current sound's volume.
sf::Time getDuration () const
 Returns the duration of the movie.
sf::Vector2f getSize () const
 Returns the size (width, height) of the currently active video stream.
void fit (float x, float y, float width, float height, bool preserveRatio=true)
void fit (sf::FloatRect frame, bool preserveRatio=true)
 Scales the movie to fit the requested frame.
float getFramerate () const
 Returns the average amount of video frames per second.
unsigned int getSampleRate () const
 Returns the amount of audio samples per second.
unsigned int getChannelCount () const
 Returns the count of audio channels.
Status getStatus () const
 Returns the current status of the movie.
sf::Time getPlayingOffset () const
 Returns the current playing position in the movie.
bool setPlayingOffset (const sf::Time &targetSeekTime)
const sf::Texture & getCurrentImage () const
 Returns the latest movie image.

Detailed Description

Main class of the sfeMovie API. It is used to open media files, provide playback and basic controls

Member Function Documentation

void sfe::Movie::fit ( float  x,
float  y,
float  width,
float  height,
bool  preserveRatio = true 
)
See Also
fitFrame(sf::FloatRect, bool)
void sfe::Movie::fit ( sf::FloatRect  frame,
bool  preserveRatio = true 
)

Scales the movie to fit the requested frame.

If the ratio is preserved, the movie may be centered in the given frame, thus the movie position may be different from the one you specified.

Note
This method will erase any previously set scale and position
Parameters
framethe target frame in which you want to display the movie
preserveRatiotrue to keep the original movie ratio, false otherwise
unsigned int sfe::Movie::getChannelCount ( ) const

Returns the count of audio channels.

Returns
the channels' count
const sf::Texture& sfe::Movie::getCurrentImage ( ) const

Returns the latest movie image.

The returned image is a texture in VRAM. If the movie has no video stream, this returns an empty texture.

Note
As in the classic update()/draw() workflow, update() needs to be called before using this method if you want the image to be up to date
Returns
the current image of the movie for the activated video stream
sf::Time sfe::Movie::getDuration ( ) const

Returns the duration of the movie.

Returns
the duration as sf::Time
float sfe::Movie::getFramerate ( ) const

Returns the average amount of video frames per second.

In case of media that use Variable Frame Rate, this value is approximative

Returns
the average video frame rate
sf::Time sfe::Movie::getPlayingOffset ( ) const

Returns the current playing position in the movie.

Returns
the playing position
unsigned int sfe::Movie::getSampleRate ( ) const

Returns the amount of audio samples per second.

Returns
the audio sample rate
sf::Vector2f sfe::Movie::getSize ( ) const

Returns the size (width, height) of the currently active video stream.

Returns
the size of the currently active video stream, or (0, 0) is there is none
Status sfe::Movie::getStatus ( ) const

Returns the current status of the movie.

Returns
See enum Status
const Streams& sfe::Movie::getStreams ( MediaType  type) const

Return a description of all the streams of the given type contained in the opened media.

Parameters
typethe stream type (audio, video...) to return
float sfe::Movie::getVolume ( ) const

Returns the current sound's volume.

Returns
the sound's volume, in range [0, 100]
bool sfe::Movie::openFromFile ( const std::string &  filename)

Attemps to open a media file (movie or audio)

Opening can fails either because of a wrong filename, or because you tried to open a media file that has no supported video or audio stream.

Parameters
filenamethe path to the media file
Returns
true on success, false otherwise
void sfe::Movie::pause ( )

Pauses the media playback.

If the media playback is already paused, this does nothing, otherwise the playback is paused.

void sfe::Movie::play ( )

Start or resume playing the media playback.

This function starts the stream if it was stopped, resumes it if it was paused, and restarts it from beginning if it was already playing. This function is non blocking and lets the audio playback happen in the background. The video playback must be updated with the update() method.

bool sfe::Movie::selectStream ( const StreamDescriptor streamDescriptor)

Request activation of the given stream.

In case another stream of the same kind is already active, it is deactivated.

Note
When opening a new media file, the default behaviour is to automatically activate the first found audio and video streams
Warning
This method can only be used when the movie is stopped
Parameters
streamDescriptorthe descriptor of the stream to activate
Returns
true if the stream could be selected (ie. valid stream and movie is stopped)
bool sfe::Movie::setPlayingOffset ( const sf::Time &  targetSeekTime)

Seek up to targetSeekTime

Parameters
targetSeekTimethe new expected playing offset
Returns
true is seeking was successfull on all the streams, false otherwise If seeking failed, it is not guaranteed to still be playable and synchronized
void sfe::Movie::setVolume ( float  volume)

Sets the sound's volume (default is 100)

Parameters
volumethe volume in range [0, 100]
void sfe::Movie::stop ( )

Stops the media playback. The playing offset is reset to the beginning.

This function stops the stream if it was playing or paused, and does nothing if it was already stopped. It also resets the playing position (unlike pause()).


The documentation for this class was generated from the following file: