Hello,
I’ve just about got my project for a class finished. Unfortunately I’ve run into a problem with sound.
When I press a button to start the thing, it plays the start of calmsound, then stops completely. When I press another button calmsound continues playing.
Can someone tell me why this is? Thanks.
import processing.sound.*;
import processing.video.*;
Movie calm1, calm2, calm3, calm4, calm5, calm6, calm7, calm8, calm9, calm10, calm11, calm12;
Movie stress1, stress2, stress3, stress4, stress5, stress6, stress7, stress8, stress9, stress10, stress11, stress12;
Movie trigger1, trigger2, trigger3, trigger4, trigger5, trigger6, trigger7, trigger8, trigger9, trigger10, trigger11, trigger12;
SoundFile calmsound, stresssound, triggersound;
boolean aPlay = false, sPlay = false, dPlay = false;
void setup(){
size(640,480);
surface.setResizable(true);
background(0,0,0);
//calm videos
calm1 = new Movie(this, "calm1.mp4");
calm2 = new Movie(this, "calm2.mp4");
calm3 = new Movie(this, "calm3.mp4");
calm4 = new Movie(this, "calm4.mp4");
calm5 = new Movie(this, "calm5.mp4");
calm6 = new Movie(this, "calm6.mp4");
calm7 = new Movie(this, "calm7.mp4");
calm8 = new Movie(this, "calm8.mp4");
calm9 = new Movie(this, "calm9.mp4");
calm10 = new Movie(this, "calm10.mp4");
calm11 = new Movie(this, "calm11.mp4");
calm12 = new Movie(this, "calm12.mp4");
//Stressful videos
stress1 = new Movie(this, "stress1.mp4");
stress2 = new Movie(this, "stress2.mp4");
stress3 = new Movie(this, "stress3.mp4");
stress4 = new Movie(this, "stress4.mp4");
stress5 = new Movie(this, "stress5.mp4");
stress6 = new Movie(this, "stress6.mp4");
stress7 = new Movie(this, "stress7.mp4");
stress8 = new Movie(this, "stress8.mp4");
stress9 = new Movie(this, "stress9.mp4");
stress10 = new Movie(this, "stress10.mp4");
stress11 = new Movie(this, "stress11.mp4");
stress12 = new Movie(this, "stress12.mp4");
//triggering videos
trigger1 = new Movie(this, "trigger1.mp4");
trigger2 = new Movie(this, "trigger2.mp4");
trigger3 = new Movie(this, "trigger3.mp4");
trigger4 = new Movie(this, "trigger4.mp4");
trigger5 = new Movie(this, "trigger5.mp4");
trigger6 = new Movie(this, "trigger6.mp4");
trigger7 = new Movie(this, "trigger7.mp4");
trigger8 = new Movie(this, "trigger8.mp4");
trigger9 = new Movie(this, "trigger9.mp4");
trigger10 = new Movie(this, "trigger10.mp4");
trigger11 = new Movie(this, "trigger11.mp4");
trigger12 = new Movie(this, "trigger12.mp4");
//Sounds
calmsound = new SoundFile(this, "calmsound.mp3");
stresssound = new SoundFile(this, "stresssound.mp3");
triggersound = new SoundFile(this, "triggersound.mp3");
}
void movieEvent(Movie m){
m.read();
}
void draw() {
if (aPlay==true) {
calmsound.loop();
if (millis() < 15000) {
calm1.loop();
calm2.pause();
calm3.pause();
calm4.pause();
calm5.pause();
calm6.pause();
calm7.pause();
calm8.pause();
calm9.pause();
calm10.pause();
calm11.pause();
calm12.pause();
image(calm1, 0, 0, width, height);
}
if (millis() > 15000 && millis() < 30000) {
calm1.pause();
calm2.play();
calm3.pause();
calm4.pause();
calm5.pause();
calm6.pause();
calm7.pause();
calm8.pause();
calm9.pause();
calm10.pause();
calm11.pause();
calm12.pause();
image(calm2, 0, 0, width, height);
}
if (millis() > 30000 && millis() < 45000) {
calm1.pause();
calm2.pause();
calm3.play();
calm4.pause();
calm5.pause();
calm6.pause();
calm7.pause();
calm8.pause();
calm9.pause();
calm10.pause();
calm11.pause();
calm12.pause();
image(calm3, 0, 0, width, height);
}
if (millis() > 45000 && millis() < 60000) {
calm1.pause();
calm2.pause();
calm3.pause();
calm4.play();
calm5.pause();
calm6.pause();
calm7.pause();
calm8.pause();
calm9.pause();
calm10.pause();
calm11.pause();
calm12.pause();
image(calm4, 0, 0, width, height);
}
if (millis() > 60000 && millis() < 75000) {
calm1.pause();
calm2.pause();
calm3.pause();
calm4.pause();
calm5.play();
calm6.pause();
calm7.pause();
calm8.pause();
calm9.pause();
calm10.pause();
calm11.pause();
calm12.pause();
image(calm5, 0, 0, width, height);
}
if (millis() > 75000 && millis() < 90000) {
calm1.pause();
calm2.pause();
calm3.pause();
calm4.pause();
calm5.pause();
calm6.play();
calm7.pause();
calm8.pause();
calm9.pause();
calm10.pause();
calm11.pause();
calm12.pause();
image(calm6, 0, 0, width, height);
}
if (millis() > 90000 && millis() < 105000) {
calm1.pause();
calm2.pause();
calm3.pause();
calm4.pause();
calm5.pause();
calm6.pause();
calm7.play();
calm8.pause();
calm9.pause();
calm10.pause();
calm11.pause();
calm12.pause();
image(calm7, 0, 0, width, height);
}
if (millis() > 105000 && millis() < 120000) {
calm1.pause();
calm2.pause();
calm3.pause();
calm4.pause();
calm5.pause();
calm6.pause();
calm7.pause();
calm8.play();
calm9.pause();
calm10.pause();
calm11.pause();
calm12.pause();
image(calm8, 0, 0, width, height);
}
if (millis() > 120000 && millis() < 135000) {
calm1.pause();
calm2.pause();
calm3.pause();
calm4.pause();
calm5.pause();
calm6.pause();
calm7.pause();
calm8.pause();
calm9.play();
calm10.pause();
calm11.pause();
calm12.pause();
image(calm9, 0, 0, width, height);
}
if (millis() > 135000 && millis() < 150000) {
calm1.pause();
calm2.pause();
calm3.pause();
calm4.pause();
calm5.pause();
calm6.pause();
calm7.pause();
calm8.pause();
calm9.pause();
calm10.play();
calm11.pause();
calm12.pause();
image(calm10, 0, 0, width, height);
}
if (millis() > 150000 && millis() < 165000) {
calm1.pause();
calm2.pause();
calm3.pause();
calm4.pause();
calm5.pause();
calm6.pause();
calm7.pause();
calm8.pause();
calm9.pause();
calm10.pause();
calm11.play();
calm12.pause();
image(calm11, 0, 0, width, height);
}
if (millis() > 165000 && millis() < 180000) {
calm1.pause();
calm2.pause();
calm3.pause();
calm4.pause();
calm5.pause();
calm6.pause();
calm7.pause();
calm8.pause();
calm9.pause();
calm10.pause();
calm11.pause();
calm12.play();
image(calm12, 0, 0, width, height);
}
}
if (sPlay==true) {
//stresssound.loop();
if (millis() < 15000) {
stress1.play();
stress2.pause();
stress3.pause();
stress4.pause();
stress5.pause();
stress6.pause();
stress7.pause();
stress8.pause();
stress9.pause();
stress10.pause();
stress11.pause();
stress12.pause();
image(stress1, 0, 0, width, height);
}
if (millis() > 15000 && millis() < 30000) {
stress1.pause();
stress2.pause();
stress3.pause();
stress4.pause();
stress5.pause();
stress6.pause();
stress7.pause();
stress8.pause();
stress9.pause();
stress10.pause();
stress11.pause();
stress12.pause();
image(stress2, 0, 0, width, height);
}
if (millis() > 30000 && millis() < 45000) {
stress1.pause();
stress2.play();
stress3.play();
stress4.pause();
stress5.pause();
stress6.pause();
stress7.pause();
stress8.pause();
stress9.pause();
stress10.pause();
stress11.pause();
stress12.pause();
image(stress3, 0, 0, width, height);
}
if (millis() > 45000 && millis() < 60000) {
stress1.pause();
stress2.pause();
stress3.pause();
stress4.play();
stress5.pause();
stress6.pause();
stress7.pause();
stress8.pause();
stress9.pause();
stress10.pause();
stress11.pause();
stress12.pause();
image(stress4, 0, 0, width, height);
}
if (millis() > 60000 && millis() < 75000) {
stress1.pause();
stress2.pause();
stress3.pause();
stress4.pause();
stress5.play();
stress6.pause();
stress7.pause();
stress8.pause();
stress9.pause();
stress10.pause();
stress11.pause();
stress12.pause();
image(stress5, 0, 0, width, height);
}
if (millis() > 75000 && millis() < 90000) {
stress1.pause();
stress2.pause();
stress3.pause();
stress4.pause();
stress5.pause();
stress6.play();
stress7.pause();
stress8.pause();
stress9.pause();
stress10.pause();
stress11.pause();
stress12.pause();
image(stress6, 0, 0, width, height);
}
if (millis() > 90000 && millis() < 105000) {
stress1.pause();
stress2.pause();
stress3.pause();
stress4.pause();
stress5.pause();
stress6.pause();
stress7.play();
stress8.pause();
stress9.pause();
stress10.pause();
stress11.pause();
stress12.pause();
image(stress7, 0, 0, width, height);
}
if (millis() > 105000 && millis() < 120000) {
stress1.pause();
stress2.pause();
stress3.pause();
stress4.pause();
stress5.pause();
stress6.pause();
stress7.pause();
stress8.play();
stress9.pause();
stress10.pause();
stress11.pause();
stress12.pause();
image(stress8, 0, 0, width, height);
}
if (millis() > 120000 && millis() < 135000) {
stress1.pause();
stress2.pause();
stress3.pause();
stress4.pause();
stress5.pause();
stress6.pause();
stress7.pause();
stress8.pause();
stress9.play();
stress10.pause();
stress11.pause();
stress12.pause();
image(stress9, 0, 0, width, height);
}
if (millis() > 135000 && millis() < 150000) {
stress1.pause();
stress2.pause();
stress3.pause();
stress4.pause();
stress5.pause();
stress6.pause();
stress7.pause();
stress8.pause();
stress9.pause();
stress10.play();
stress11.pause();
stress12.pause();
image(stress10, 0, 0, width, height);
}
if (millis() > 150000 && millis() < 165000) {
stress1.pause();
stress2.pause();
stress3.pause();
stress4.pause();
stress5.pause();
stress6.pause();
stress7.pause();
stress8.pause();
stress9.pause();
stress10.pause();
stress11.play();
stress12.pause();
image(stress11, 0, 0, width, height);
}
if (millis() > 165000 && millis() < 180000) {
stress1.pause();
stress2.pause();
stress3.pause();
stress4.pause();
stress5.pause();
stress6.pause();
stress7.pause();
stress8.pause();
stress9.pause();
stress10.pause();
stress11.pause();
stress12.play();
image(stress12, 0, 0, width, height);
}
}
if (dPlay==true) {
//triggersound.play();
if (millis() < 15000) {
trigger1.play();
trigger2.pause();
trigger3.pause();
trigger4.pause();
trigger5.pause();
trigger6.pause();
trigger7.pause();
trigger8.pause();
trigger9.pause();
trigger10.pause();
trigger11.pause();
trigger12.pause();
image(trigger1, 0, 0, width, height);
}
if (millis() > 15000 && millis() < 30000) {
trigger1.pause();
trigger2.pause();
trigger3.pause();
trigger4.pause();
trigger5.pause();
trigger6.pause();
trigger7.pause();
trigger8.pause();
trigger9.pause();
trigger10.pause();
trigger11.pause();
trigger12.pause();
image(trigger2, 0, 0, width, height);
}
if (millis() > 30000 && millis() < 45000) {
trigger1.pause();
trigger2.play();
trigger3.play();
trigger4.pause();
trigger5.pause();
trigger6.pause();
trigger7.pause();
trigger8.pause();
trigger9.pause();
trigger10.pause();
trigger11.pause();
trigger12.pause();
image(trigger3, 0, 0, width, height);
}
if (millis() > 45000 && millis() < 60000) {
trigger1.pause();
trigger2.pause();
trigger3.pause();
trigger4.play();
trigger5.pause();
trigger6.pause();
trigger7.pause();
trigger8.pause();
trigger9.pause();
trigger10.pause();
trigger11.pause();
trigger12.pause();
image(trigger4, 0, 0, width, height);
}
if (millis() > 60000 && millis() < 75000) {
trigger1.pause();
trigger2.pause();
trigger3.pause();
trigger4.pause();
trigger5.play();
trigger6.pause();
trigger7.pause();
trigger8.pause();
trigger9.pause();
trigger10.pause();
trigger11.pause();
trigger12.pause();
image(trigger5, 0, 0, width, height);
}
if (millis() > 75000 && millis() < 90000) {
trigger1.pause();
trigger2.pause();
trigger3.pause();
trigger4.pause();
trigger5.pause();
trigger6.play();
trigger7.pause();
trigger8.pause();
trigger9.pause();
trigger10.pause();
trigger11.pause();
trigger12.pause();
image(trigger6, 0, 0, width, height);
}
if (millis() > 90000 && millis() < 105000) {
trigger1.pause();
trigger2.pause();
trigger3.pause();
trigger4.pause();
trigger5.pause();
trigger6.pause();
trigger7.play();
trigger8.pause();
trigger9.pause();
trigger10.pause();
trigger11.pause();
trigger12.pause();
image(trigger7, 0, 0, width, height);
}
if (millis() > 105000 && millis() < 120000) {
trigger1.pause();
trigger2.pause();
trigger3.pause();
trigger4.pause();
trigger5.pause();
trigger6.pause();
trigger7.pause();
trigger8.play();
trigger9.pause();
trigger10.pause();
trigger11.pause();
trigger12.pause();
image(trigger8, 0, 0, width, height);
}
if (millis() > 120000 && millis() < 135000) {
trigger1.pause();
trigger2.pause();
trigger3.pause();
trigger4.pause();
trigger5.pause();
trigger6.pause();
trigger7.pause();
trigger8.pause();
trigger9.play();
trigger10.pause();
trigger11.pause();
trigger12.pause();
image(trigger9, 0, 0, width, height);
}
if (millis() > 135000 && millis() < 150000) {
trigger1.pause();
trigger2.pause();
trigger3.pause();
trigger4.pause();
trigger5.pause();
trigger6.pause();
trigger7.pause();
trigger8.pause();
trigger9.pause();
trigger10.play();
trigger11.pause();
trigger12.pause();
image(trigger10, 0, 0, width, height);
}
if (millis() > 150000 && millis() < 165000) {
trigger1.pause();
trigger2.pause();
trigger3.pause();
trigger4.pause();
trigger5.pause();
trigger6.pause();
trigger7.pause();
trigger8.pause();
trigger9.pause();
trigger10.pause();
trigger11.play();
trigger12.pause();
image(trigger11, 0, 0, width, height);
}
if (millis() > 165000 && millis() < 180000) {
trigger1.pause();
trigger2.pause();
trigger3.pause();
trigger4.pause();
trigger5.pause();
trigger6.pause();
trigger7.pause();
trigger8.pause();
trigger9.pause();
trigger10.pause();
trigger11.pause();
trigger12.play();
image(trigger12, 0, 0, width, height);
}
}
}
void keyPressed() {
if (key == 'a'){
aPlay = true;
sPlay = false;
dPlay = false;
}
if (key == 's'){
aPlay = false;
sPlay = true;
dPlay = false;
}
if (key == 'd'){
aPlay = false;
sPlay = false;
dPlay = true;
}
}