# Having problems with buttons/sound on cellphone

**URL:** <https://discourse.processing.org/t/having-problems-with-buttons-sound-on-cellphone/18579>\
**Category:** Libraries\
**Created:** [March 11, 2020, 12:36am UTC](https://discourse.processing.org/t/having-problems-with-buttons-sound-on-cellphone/18579 "2020-03-11T00:36:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![KatGreen](https://avatars.discourse-cdn.com/v4/letter/k/bc79bd/32.png) [@KatGreen](https://discourse.processing.org/u/KatGreen)\
**Post date:** [March 11, 2020, 12:36am UTC](https://discourse.processing.org/t/having-problems-with-buttons-sound-on-cellphone/18579/1 "2020-03-11T00:36:52Z")

</div>

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:

```auto

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)
}

```

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [March 11, 2020, 4:38am UTC](https://discourse.processing.org/t/having-problems-with-buttons-sound-on-cellphone/18579/2 "2020-03-11T04:38:59Z")

</div>

Please edit your previous post, select your code and hit this button `</>` the properly format the code in the forum.

If you try this [button example](https://p5js.org/examples/dom-input-and-button.html) from the P5.js website, what are your results?

Kf
