Questions about mp3 audio player I am creating

Hi there…

I am building a mp3 player window. I simply call an HTML page that has a swf loaded that has a background image and a time bar on the bottom.

Everything loads automatically. I actually want to start it by a play button and be able to stop it at any point along the time line and then resume playing at that particular point again - like a pause button.

I am looking at this code I found… but I am not sure that it will do what I want. Plus I want make the file not play until the play button is pressed. How is this done.

Here is what I am looking at:


// This creates the sound object, attaches it and starts it playing/looping 1000 times from the very beginning
var mySound:Sound = new Sound();
mySound.attachSound("linkageID");
mySound.start(0, 1000);

// This is for the start button
_root.stopStart.audioPlay.onRelease=function() {
  _root.stopStart.gotoAndPlay(1);
  mySound.start(0, 1000);
}

// This is for the stop button button
_root.stopStart.audioStop.onRelease=function() {
  _root.stopStart.gotoAndPlay(2);
  mySound.stop();
}

Your comments are welcomed!

What exactly is the mySound.attachSound(“linkageID”);?

What is the linkageID supposed to be?

Do I need any onClick code to make the buttons clickable and to make the cursor select the button?

You missed my question stranger??? is this the same RMFRED of WYoming?

I take it that I need to add this to my layer where my play button is located?

Does this stop the sound file at any particular place? How do you start the file up from that same place again. Like a pause button?

Best to keep the sound in the library and not have it on the timeline at all.
The layer names have no relevance to scripting and are only there as a reminder, they cannot be referred to porgramtically.

No, adding script specifically to a layer or on an object is outdated, the play button should have an instance name from which it can be referred to from any layer.

The value stores the played time when it gets paused (stopped).
This value is then used to start again (unpaused) from the correct time.

The layer is irrelevant to the script location when triggering sounds via script.
It’s best to keep all script in one frame rather than scatter it about on objects/frames if possible.

linkageID is whatever you name the sound as a linkage name within the library properties of the sound

In this sound object, am I to put the layer name where the audio file is introduced to the timeline as the “new sound”?

var mySound:Sound = new Sound();

ie…

var mySound:Sound = layer Name();

or

var mySound:Sound = file Name();

So when I create this sound object; where do I introduce this script? To my sound layer??

// This creates the sound object, attaches it and starts it playing/looping 1000 times from the very beginning
var mySound:Sound = new Sound();
mySound.attachSound("linkageID");
mySound.start(0, 1000);

If you don’t want the sound to play automatically omit the mySound.start line, and only place that in your play button handler.

You’ll also need to store the current play position in a variable e.g:

mySoundPosition = 0;

then in the play button handler

mySound.start(mySoundPosition, 1000);

and in your stop handler

mySoundPosition = mySound.position/1000;

This code is a little old but works and validates xhtml strict.
<script type=“text/javascript” src=“embed/swfobject.js”></script>
<div id=“player”>This text gets replaced</div>
<script type=“text/javascript”>
var so = new SWFObject(‘embed/mediaplayer.swf’,‘mpl’,‘400’,‘20’,‘8’);
so.addParam(‘allowscriptaccess’,‘always’);
so.addParam(‘allowfullscreen’,‘true’);
so.addVariable(‘height’,‘20’);
so.addVariable(‘width’,‘400’);
so.addVariable(‘file’,‘media/jwasparc.mp3’);
so.addVariable(‘backcolor’,‘0xf3edcd’);
so.addVariable(‘frontcolor’,‘0x003960’);
so.addVariable(‘lightcolor’,‘0x003960’);
so.addVariable(‘screencolor’,‘0x003960’);
so.write(‘player’);
</script>

google for the swfobject js file or I can send it to you

Drag a movieclip from the library onto the stage. Select it, then in the properties panel you can name it.

Not really, I presume you are referring to the name the clip has within the library, which is not relevant to actionscript.

In the properties panel, when you have selected a clip on stage, there is a field marked <instance name> which is the name assigned to a particular copy of the movieclip on stage.

Is this the same as calling it a symbol?

Hi there… Can any body tell me how to create an instance?