# Why won't my audio stop?

**URL:** <https://forum.kirupa.com/t/why-wont-my-audio-stop/261861>\
**Category:** flash\
**Created:** [May 31, 2008, 11:43pm UTC](https://forum.kirupa.com/t/why-wont-my-audio-stop/261861 "2008-05-31T23:43:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ScoobyDooobyD00](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@ScoobyDooobyD00](https://forum.kirupa.com/u/ScoobyDooobyD00)\
**Post date:** [May 31, 2008, 11:43pm UTC](https://forum.kirupa.com/t/why-wont-my-audio-stop/261861/1 "2008-05-31T23:43:18Z")

</div>

Hi, I’m building an mp3 player in Flash and it will load the audio and play it but it won’t pause. Here’s my code.

```php
onLoad(pauseIt());
// Check to see if song url is included.
// See if song url is specified
if(!song_url) {
	// If not then stop movie and display frame error
	playPause.gotoAndStop("error");
}else {
// Set up sound variable
var my_sound:Sound = new Sound();

// Load Audio
my_sound.loadSound(song_url, true);

// Set Volume to 100%
my_sound.setVolume(100);

// Position of Music
var pos:Number;

// ------- Pausing and unPausing functions ------- \\

// Pauses the music
function pauseIt():Void {
	pos = my_sound.position;
	my_sound.stop();
}

// Pauses the music
function playIt():Void {
	my_sound.start(pos/1000);
}

// Play/Pause Toggle
playPause.onRollOver = function() {
	if(this._currentframe == 1) this.gotoAndStop("PlayOver");
	else this.gotoAndStop("PauseOver");
}

playPause.onRollOut = playPause.onReleaseOutside = function() {
	if(this._currentframe == 10) this.gotoAndStop("Play");
	else this.gotoAndStop("Pause");
}

playPause.onRelease = function() {
	if(this._currentframe == 10) {
		this.gotoAndStop("PauseOver");
		pauseIt();
	}else {
		this.gotoAndStop("PlayOver");
		playIt();
	}
}
}

```

Thanks in advance

---

<div class="post-metadata">

**Author:** ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)\
**Post date:** [June 1, 2008, 7:26pm UTC](https://forum.kirupa.com/t/why-wont-my-audio-stop/261861/2 "2008-06-01T19:26:20Z")

</div>

song\_url=“song.mp3”;  
btn.onRelease=function()  
{  
pauseIt();  
}  
// ------- Pausing and unPausing functions ------- \

// Pauses the music  
function pauseIt():Void {  
pos = my\_sound.position;  
my\_sound.stop();  
}

// Pauses the music  
function playIt():Void {  
my\_sound.start(pos/1000);  
}

//onLoad(pauseIt());  
// Check to see if song url is included.  
// See if song url is specified  
if(!song\_url) {  
// If not then stop movie and display frame error  
playPause.gotoAndStop(“error”);  
}else {  
// Set up sound variable  
var my\_sound:Sound = new Sound();

// Load Audio  
my\_sound.loadSound(song\_url, true);

// Set Volume to 100%  
my\_sound.setVolume(100);

// Position of Music  
var pos:Number;

// Play/Pause Toggle  
playPause.onRollOver = function() {  
if(this.\_currentframe == 1) this.gotoAndStop(“PlayOver”);  
else this.gotoAndStop(“PauseOver”);  
}

playPause.onRollOut = playPause.onReleaseOutside = function() {  
if(this.\_currentframe == 10) this.gotoAndStop(“Play”);  
else this.gotoAndStop(“Pause”);  
}

playPause.onRelease = function() {  
if(this.\_currentframe == 10) {  
this.gotoAndStop(“PauseOver”);  
pauseIt();  
}else {  
this.gotoAndStop(“PlayOver”);  
playIt();  
}  
}  
}

//------------------------------------------------

well you code seems to work just on registering the pauseit() and playit() functions in the begining lines… of the actionscript codes

just used a button called btn to test it… seems to be fine…
