Book Image

OpenFrameworks Essentials

Book Image

OpenFrameworks Essentials

Overview of this book

Table of Contents (19 chapters)
openFrameworks Essentials
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Playing a video file


openFrameworks supports video files of various formats, including MP4, MOV, and AVI. The class for playing videos is ofVideoPlayer.

Note

For playing videos with openFrameworks on Windows, you need to have Apple's QuickTime installed. It's free to download from apple.com. (Please, restart Windows after installing.)

Let's load a video file and play it on the screen in the following way:

  1. Add the video object definition to the ofApp class:

    ofVideoPlayer video;
  2. Add the commands to load the video from the flowing.mp4 file and starting it to play by inserting the following lines to setup():

    video.loadMovie( "flowing.mp4" );
    video.play();
  3. Add the command to update video objects regularly by inserting the following line to update():

    video.update();

    Note

    This command manages the loading of new video frames when it is needed, so we should call it regularly to have proper and smooth video playback.

  4. Add the commands to draw the current video frame by inserting the following lines to draw(),...