@Pi_Lou wrote:
I am trying to play a single video multiple times (for exemple each time a key is pressed) and at random <X;Y> positions…
That much I can do.But
the new ofVideoPlayer clone must restart the video. and I realized that all ofVideoPlayer clones are playing each video at the same position. which means that even if I press keys with delay all videos will end simultaneously.this is my code so far
ofApp.h
ofVideoPlayer mainPlayer; vector<ofVideoPlayer> players;
ofApp.cpp
void ofApp::setup() { mainPlayer.load(dir.getPath(i)); mainPlayer.setLoopState(OF_LOOP_NONE); } void ofApp::update(){ int id = 0; for (auto &player : players) { if (player.isPlaying()) { player.update(); } else { players.erase(players.begin()+id); id--; } id++; } } void ofApp::draw(){ //Draw all players for (auto &player : players) { player.draw(randomX, randomX, width-randomW, height-randomH); } } void ofApp::keyPressed(int key){ ofVideoPlayer playerClone; playerClone.setPlayer(player.getPlayer()); //Also tried with same results : playerClone = player; players[videoID].play(); players.push_back(playerClone); }
Thanks a lot for your help
Cheers
Posts: 2
Participants: 2