#include <video.h>
Public Member Functions | |
Video (const std::string &path) | |
virtual | ~Video () |
Video (Video &)=delete | |
Video & | operator= (const Video &)=delete |
Video (Video &&)=delete | |
Video & | operator= (Video &&)=delete |
virtual bool | init (utility::ErrorState &errorState) |
Frame | update (double deltaTime) |
void | play (double time=0.0) |
bool | isPlaying () const |
void | stop (bool blocking) |
void | seek (double seconds) |
double | getCurrentTime () const |
double | getDuration () const |
int | getWidth () const |
int | getHeight () const |
const std::string & | getPath () const |
bool | hasAudio () const |
bool | audioEnabled () const |
Public Attributes | |
bool | mLoop = false |
If the video needs to loop. More... | |
float | mSpeed = 1.0f |
Video playback speed. More... | |
nap::Signal< Video & > | mDestructedSignal |
This signal will be emitted before the Video resource is destructed. More... | |
Decodes a video using FFMPEG in the background. It is NOT recommended to manually (at run-time) create a nap::Video. Use the nap::VideoPlayer instead. The nap::VideoPlayer consumes frames, produced by a video, when they are ready to be presented. This object does not contain any textures, only FFMPEG related content.
Call init() after construction and start() / stop() afterwards. On initialization the video file is opened, streams are extracted and the video / audio state is initialized. A video stream is required, the audio stream is optional. Use a nap::VideoAudioComponent to decode and output the audio stream. On start() the IO and decode threads are spawned. On stop() the IO and decode threads are stopped. The av and codec contexts are freed on destruction. Keeping the format and codec contexts in memory ensures the loaded video can be started and stopped fast.
Video | ( | const std::string & | path | ) |
path | the video file on disk |
|
virtual |
bool audioEnabled | ( | ) | const |
Returns if audio decoding and playback is enabled. This is the case when there is an audio stream available and audio decoding is explicitly enabled.
double getCurrentTime | ( | ) | const |
double getDuration | ( | ) | const |
int getHeight | ( | ) | const |
const std::string& getPath | ( | ) | const |
int getWidth | ( | ) | const |
bool hasAudio | ( | ) | const |
|
virtual |
Initializes the video. Finds decoder, sets up everything necessary to start playback.
errorState | Contains detailed information about errors if this function return false. |
bool isPlaying | ( | ) | const |
Check whether the video is currently playing
void play | ( | double | time = 0.0 | ) |
Starts playback of the video at the given time in seconds. This will spawn the video IO and decode threads in the background. Video is stopped before being started.
time | the offset in seconds to start the video at. |
void seek | ( | double | seconds | ) |
Seeks within the video to the time provided. This can be called during playback.
seconds | video offset in seconds. |
void stop | ( | bool | blocking | ) |
Stops playback of the video. The video IO and decode threads are stopped.
blocking | if the calling thread waits for the IO and decode thread to stop. |
Frame update | ( | double | deltaTime | ) |
Returns a newly decoded frame if available, an invalid frame otherwise. Always call .free() after processing frame content! This is a non-blocking call.
deltaTime | time in seconds in between calls. |
nap::Signal<Video&> mDestructedSignal |
This signal will be emitted before the Video resource is destructed.
bool mLoop = false |
If the video needs to loop.
float mSpeed = 1.0f |
Video playback speed.