ofVideoPlayer copy


Hi list,

I try to copy a ofVideoPlayer object which works fine.

void ofApp::keyReleased(int key){
	switch (key) {
	case 's':
		video1 = video2;     // gives the expected result
		video2.close();    // this line leads to both videos being closed

Afterwards the videos seem connected, so video1.setPaused(1); is stopping both videos, video2.setPaused(1); does the same.
Only the method load() seems to sort of reset, but I want to prevent loading an already loaded video.
Is there a way to copy all “content” of video2 to video1, so that the objects do not get “connected”
that way?

thanks for any hint!


in short, no, anything that is in the gl folder in OF or has GL objects (like the texture in ofVideoPlayer) is shallowed copied to avoid copies of the GL objects which can be hard or expensive to copy. Also because usually people don’t want to copy a videoplayer but need a copy operator to put it on a vector for example (mostly pre-c++11)

Why would you want to copy a video player? you can always draw it twice (or as much as you need) from one copy alone but if you need it twice to draw different frames at the same time just load the same video twice, it’s really the same or even cheaper than copying it would be


OK, thanks a lot for the explanation!

My App is planned in a way it would come in handy (a vector of actual videos and a vector of target videos for fading. So after fading I planned to copy target to actual video and delete target video). But I’ll just change my code and be fine.

have a great day!