Skip to content

Instantly share code, notes, and snippets.

@urshofer
Created November 13, 2015 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urshofer/511c28d970085a6afd59 to your computer and use it in GitHub Desktop.
Save urshofer/511c28d970085a6afd59 to your computer and use it in GitHub Desktop.
#include "ofMain.h"
#include "ofApp.h"
//========================================================================
int main( ){
ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp(new ofApp());
}
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
MO[0].setLoopState(OF_LOOP_NONE);
MO[1].setLoopState(OF_LOOP_NONE);
MOPointer = 0;
}
//--------------------------------------------------------------
void ofApp::update(){
static int lastMod = ofGetElapsedTimeMillis();
static int action = 0;
static int moviecount = 1;
static string movieFile = "";
if (ofGetElapsedTimeMillis() - lastMod > 500) {
if (action == 0) {
cout << "Append " << ofToString(moviecount) << ".mp4" << endl;
movieFile = ofToString(moviecount) + ".mp4";
/* MO[MOPointer].close();*/
MO[MOPointer].loadAsync(movieFile);
action++;
if (moviecount < 3)
moviecount ++;
else
moviecount = 1;
}
else if (action == 1) {
action = 0;
MO[MOPointer].play();
MOPointer = MOPointer == 1 ? 0 : 1;
}
lastMod = ofGetElapsedTimeMillis();
}
MO[0].update();
MO[1].update();
}
//--------------------------------------------------------------
void ofApp::draw(){
MO[0].draw(0,20 , 320, 240);
MO[1].draw(330,20 , 320, 240);
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}
#pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp{
public:
ofVideoPlayer MO[2];
int MOPointer;
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseEntered(int x, int y);
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment