Hi everyone!
I’m having some problem playing some thread-loaded videos.
The procedure I use seems to be correct, also searching for it in our forum:
- setUseTexture(false)
- in thread use loadMovie(moviePath) that notify a loadDone event.
- in my application, i catch the event and set the useTexture to true
- at every update cycle I idleMovie() the video.
- i draw the movie();
The problem is that i always see a completely white texture.
What am I doin’ wrong?
Thank you so much in advance!
VideoLoaderThread:
[...]
void VideoLoaderThread::loadVideo() {
currVideo->setUseTexture(false);
bool ret = currVideo->loadMovie(strVideoPath);
isVideoReady = ret;
if(ret){
ofNotifyEvent(loadDone, strVideoPath);
}
else{
ofNotifyEvent(loadError, strVideoPath);
}
}
//--------------------------------------------------------------
void VideoLoaderThread::updateThread() {
int start = ofGetElapsedTimeMillis();
loadVideo();
int end = ofGetElapsedTimeMillis();
}
void VideoLoaderThread::load(){
start();
updateOnce();
}
My application callback:
void myApp::videoLoaded(string &str){
ofLog(OF_LOG_NOTICE, "[SYS] EVT - videoLoaded: " + str);
vPack[currPack].videoPl = vPack[currPack].thVideoLoader->getVideo();
vPack[currPack].videoPl->setUseTexture(true);
vPack[currPack].videoPl->update();
vPack[currPack].videoPl->setAnchorPercent(0.5, 0.5);
}
in my app update:
if(oldAppProgress != appProgress){// things to be done only at the first change
ofLog(OF_LOG_NOTICE, "[SYS] ::SHOWINGVIDEO::");
vPack[currPack].videoPl->setLoopState(OF_LOOP_NONE);
oldAppProgress = appProgress;
}
vPack[currPack].videoPl->idleMovie();
// this if-clause was added for trying to update them by my own (still not working)
if( vPack[currPack].videoPl->isFrameNew() ){
ofTexture tex = vPack[currPack].videoPl->getTextureReference();
tex.allocate(vPack[currPack].videoPl->width, vPack[currPack].videoPl->height, GL_RGB);
tex.loadData(vPack[currPack].videoPl->getPixels(), vPack[currPack].videoPl->width, vPack[currPack].videoPl->height, GL_RGB);
}