We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I need help please, how could make according to press a key "1" play in random select from a list of videos, while its pressed? (the video start playing on loop, so that the list is just a video. Not play the next, until you release the key (else background = 0) or (stop all), when press key "1" (or 2) again then random looks again in "one" list).
--any ideas?, is not important for my use array-- code:
import processing.video.*;
String[] one = {"1.mov","2.mov","3.mov"};
String[] two = {"4.mov","5.mov","6.mov"};
String[] three = {"7.mov","8.mov","9.mov"};
Movie myMovie; //Movie
int a = 0;
float md = 0;
float mt = 0;
void setup() {
size(400, 400);
}
void draw(){
if (keyPressed) {
if (key == '1' {
for (int i = 1; i < myMovie.length; i ++ ) { myMovies[i] = new Movie(this, one);
myMovies[i].loop();
}
}
} else background(0);
//////////////////////////
if (keyPressed) {
if (key == '2' {
for (int i = 1; i < myMovie.length; i ++ ) { myMovies[i] = new Movie(this, two);
myMovies[i].loop();
}
}
} else background(0);
/////////////////////////////
if (keyPressed) {
if (key == '3' {
for (int i = 1; i < myMovie.length; i ++ ) { myMovies[i] = new Movie(this, three);
myMovies[i].loop();
}
}
} else background(0);
//myMovie = new Movie(this, one[int(random(i.length))]);
// myMovie.play();
}
Answers
sorry i am a new user
Highlight code text and hit CTRL+K in order to format it for the forum!
http://forum.processing.org/two/discussion/6570/multiple-key-presses
well, its good to play keys, but how can take random video of a list, when pressed a key. I'm not yet resolved. code: import processing.video.*;
You did a good move by going from the keyPressed variable in draw() to the keyPressed() function. You probably also need to use the keyReleased() function.
I rarely use (if ever) the video library, but I believe you have to use .play() on the movie you want to see. Perhaps it is the source of the error you point to.
BTW, "here is error" is useful, but it would be even better to copy & paste the error message in the forum, so we get an idea... (we often cannot run the code shown, sometime lacking the libraries, or just lacking the assets).
Only the Movie[] array is instantiated. I can't spot any movie loading anywhere and assigned to some array's slot!!!
Yes, it was done in the first version of the code, but omitted in the second one...
oh sorry Philho that's what I'll do. this it's the first line: import processing.video.*;
you know
Gotoloop, all videos are in data folder and his names are: 1,2,3...
As mentioned, you don't load those 1, 2, 3 movie files at all in the example you provided! /:)
You've merely instantiated an array, but its "slots" are still
null
empty! :-Shttp://processing.org/reference/Array.html
sorry my brain no anwser, :-O , i don't know how put the array and radom guys that's it all:
Variable nowPlaying doesn't exist! Actually, it isn't even necessary b/c you already got an index variable! 8-X
For example @ your line #25 rather than nowPlaying, you coulda used your array w/ current index:
image(movies[index], 0, 0, width, height);
Another tip: Inside Processing's IDE, hit CTRL+T in order to auto-format the code! ;;)
Fantastic man, thank you :-* [-O<
but please, i have 2 problems: 1-random its good but only the first time run, need run again to load a new diferent video. (will be good change push other key or released key or goto firstline)
2-how can i go to black screen when push "z" and load a new video random when push q again? (this last could be resolve problems 1 )
As I had pointed at my previous answer, you were already using variable index as a way to track down which Movie is currently being played!
Variables mov_a, mov_b, mov_c, nowPlaying are completely redundant!
Either go w/ index or nowPlaying, not both approaches! [-X
jajajajajaj :))
i love it [-X
i can eliminate a, b and c, and change index for nowplaying, but I do not know how to do yours 3 points, X_X , please write me lines 8-}
·Following the index approach, within keyPressed(), pause() current index Movie. where go pause? delete "keyPressed"?
·Then pick up a diff. random() value for index. I don't understand, sorry (i'm spanish EU)
·Finally, loop() that chosen index Movie. I don't know how to do. My knowledge have a limits. thanks over there :o3 :o3 :o3
Something like this: *-:)
thank you for your present, you are a brilliant =D>
now i learn a "little bit" thank you to you
Hello my friends :)
I use coding here and I have a little problem. I added command movies[index].play(); and my video plays. When it's done I see last frame. Correct.
But when I put Q and playing other video, the second video makes playing and when it's done, it makes loop. How can stop loop second video.
Could you provide all your code, or at least a minimum amount of code showing your approach? In the snippet that you provided, it is not a good idea to call line 5 in draw. You see, you are calling that line 60 times a second [-(
Kf
Hello,
As it stands this code pics one randomised image from my data folder, whenever a capacitive sensor is held down.
I am wanting to replace these images with video files however, I am not sure how to do this.
Any help would be greatly appreciated!
please stop posting the same code all over the forum.
you have a dedicated thread for this, what do you think you'll gain by resurrecting another thread from 2014?