Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Creating a music play button to play an mp3 file

New Here ,
Mar 24, 2009 Mar 24, 2009
I am creating a music site in flash. I would like to have it list out our clients music files for people to stream simply by clicking a button. Just the corresponding file, not a list of mp3.s - just one. When they click it a second time it will stop playing. No volume control needed. Can someone help me with this command? For some reason I can't find any documentation for mp3 files here or on the web - instead they point me to 'create your mp3 player in flash here' and it's branded or more than I need.

A good example is from this site: http://terrorbird.com/ under the Jukebox column. Those play buttons are what I need.
TOPICS
ActionScript
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 24, 2009 Mar 24, 2009
Here is a basic tutorial that will help get you started, building out your own music player in AS3:
http://flashspeaksactionscript.com/create-a-mini-music-player-in-as3/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 24, 2009 Mar 24, 2009
Too bad I can't get that script to work.

On the flash page I will have - say - 5 bands listed. By each will be a song title and then the option to click play or stop. That script didn't seem to work (i posted my issues with it on their page). Any other suggestions?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 24, 2009 Mar 24, 2009
This works for me:

package
{
import flash.display.MovieClip;
import flash.events.*;
import flash.media.*;
import flash.net.URLRequest;

public class SoundLoader extends MovieClip
{
private var isPlaying:Boolean = false;
private var snd:Sound = new Sound();
private var channel:SoundChannel = new SoundChannel();
private var pos:Number = 0;
private var soundVolume:Number = 1;

public function SoundLoader()
{
snd.load(new URLRequest("something.mp3"));
btn_Stop.addEventListener(MouseEvent.CLICK, stopMusic);
btn_Stop.buttonMode = true;

btn_Play.addEventListener(MouseEvent.CLICK, playMusic);
btn_Play.buttonMode = true;
}

private function stopMusic(evt:Event):void
{
channel.stop();
pos = 0;
isPlaying = false;
}

private function playMusic(evt:Event):void
{
if(!isPlaying)
{
channel = snd.play(pos);
btn_Play.visible = false;
btn_Pause.visible = true;
isPlaying = true;
}
}
}
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 19, 2009 Apr 19, 2009

Do you add this to the button or on an empty frame? I am newbie.. please can anyone point to me a tutorial, because I have the same problem

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 19, 2009 Apr 19, 2009

This actually refers to a class file (external flash file).

for example if the class name was: Myclass.as

Store the file in the same directory as your swf and fla. Then in frame one enter:

//first import the class file

import game.SoundLoader;

// create an instance

var myCoolSound:SoundLoader = new SoundLoader();

// now you can use it in your AS

Let us know if you still have a problem.

Message was edited by: >Vee<

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 20, 2009 Apr 20, 2009
LATEST

Thanks Vee, but it is alll greek to me... maybe i should start from scratch. Thanks again

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines