Skip to content

Instantly share code, notes, and snippets.

@lab101
Created March 1, 2016 19:40
Show Gist options
  • Save lab101/8fa4db46feceb1f5eab4 to your computer and use it in GitHub Desktop.
Save lab101/8fa4db46feceb1f5eab4 to your computer and use it in GitHub Desktop.
#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
#include "cinder/qtime/QuickTimeGl.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class qttestApp : public App {
public:
void setup() override;
void mouseDown( MouseEvent event ) override;
void update() override;
void draw() override;
void loadMovieFile( const fs::path &path );
gl::TextureRef mFrameTexture;
qtime::MovieGlRef mMovie;
};
void qttestApp::setup()
{
// fs::path moviePath = getOpenFilePath();
ci::fs::path moviePath = ci::app::getAssetPath("test.mov");
if( ! moviePath.empty() )
loadMovieFile( moviePath );
}
void qttestApp::loadMovieFile( const fs::path &moviePath )
{
try {
// load up the movie, set it to loop, and begin playing
mMovie = qtime::MovieGl::create( moviePath );
mMovie->setLoop();
mMovie->play();
}
catch( ci::Exception &exc ) {
console() << "Exception caught trying to load the movie from path: " << moviePath << ", what: " << exc.what() << std::endl;
mMovie.reset();
}
mFrameTexture.reset();
}
void qttestApp::mouseDown( MouseEvent event )
{
}
void qttestApp::update()
{
if( mMovie )
mFrameTexture = mMovie->getTexture();
}
void qttestApp::draw()
{
gl::clear( Color( 0, 0, 0 ) );
gl::clear( Color( 0, 0, 0 ) );
if( mFrameTexture ) {
Rectf centeredRect = Rectf( mFrameTexture->getBounds() ).getCenteredFit( getWindowBounds(), true );
gl::draw( mFrameTexture, centeredRect );
}
}
CINDER_APP( qttestApp, RendererGl )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment