Hello everyone,
fist timer here so sorry if I am making a mess of this post: I’ve created this really simple page with three buttons: track 1, track 2 and STOP.
Track 1 - plays track 1 (and stops track 2 if it’s playing)
Track 2 - plays track 2 ( and stops track 1 if it’s playing)
STOP is pretty obvious
The buttons all function as they should on my laptop but when I try it on my cellphone they don’t work.
Thank you for any help!
Here is the sketch:
let bell; // Create a new variable called bell
let track1; // Create a new variable called track1
let track2; // Create a new variable called track2
let button1;
let button2;
let button3;
function preload() { // preload your media
soundFormats('mp3', 'wav','m4a'); // List the SoundFile formats you will include. Options: 'mp3' 'wav' 'ogg'
bell = loadSound('doorbell.mp3'); // place doorbell.mp3 into the bell variable
track1 = loadSound('abuse.m4a'); // place doorbell.mp3 into the bell variable
track2 = loadSound('2.wav'); // place doorbell.mp3 into the bell variable
}
function setup() {
createCanvas(windowWidth, windowHeight);
//bell.setVolume(0.5); // set the volume to half
//bell.play(); // play the sound
button1 = createButton("Click me: I'm track 1");
button1.position(width/2, height/2 -50);
button1.mousePressed(whenButton1Clicked);
button2 = createButton("Click me: I'm track 2");
button2.position(width/2, height/2);
button2.mousePressed(whenButton2Clicked);
button3 = createButton("STOP");
button3.position(width/2, height/2 +50);
button3.mousePressed(whenButton3Clicked);
}
function whenButton1Clicked() {
track1.stop(); // stop track 1 (if it's playing)
track2.stop(); // stop track 2 (if it's playing)
track1.loop(); // play track 1
}
function whenButton2Clicked() {
track1.stop(); // stop track 1 (if it's playing)
track2.stop(); // stop track 2 (if it's playing)
track2.play(); // play track 2
}
function whenButton3Clicked() {
track1.stop(); // stop track 1 (if it's playing)
track2.stop(); // stop track 2 (if it's playing)
}