0 Replies - 1042 Views - Last Post: 29 March 2012 - 05:42 AM

#1 matthewsch  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-March 12

Having trouble with flash mp3 player

Posted 29 March 2012 - 05:42 AM

I am trying to create a streaming mp3 player that streams from a http server in flash. I can get it to work in flash when I debug it but when I publish it to see if it works live I get nothing. Here is the code that I am using can someone give me so advice on how to get this to work live. Thanks for your help.

Frame 1.
stop();
var songURL:URLRequest;
songURL = new URLRequest("http://amber.streamguys.com:5640");
gotoAndStop(3);




Frame 2.
songURL = new URLRequest("http://amber.streamguys.com:5640");



Frame 3.
stop();
var snd:Sound = new Sound();
var channel:SoundChannel;
var context:SoundLoaderContext = new SoundLoaderContext(5000, true);
snd.load(songURL, context);
channel = snd.play(pausePosition); // Start playing
// Set "isPalying" to true now that song is playing
isPlaying = true;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Make play button show the pause symbol on it
playBtn.gotoAndStop(2);
// Stop Button Function
//function stopPlayer (event:MouseEvent):void {
	//channel.stop();
//}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Play & Pause Function //////////////////////////////////////////////////////
function playPause(event:MouseEvent):void {
   
   if (isPlaying == true) {
	   
	   pausePosition = channel.position;
      channel.stop();
	   playBtn.gotoAndStop(1);
       isPlaying = false;

    } else {
			 
       channel = snd.play(pausePosition);
	   playBtn.gotoAndPlay(2);
	   isPlaying = true;
	}

}

// Button Listeners ///////////////////////////////////////////////////////////////////////
playBtn.addEventListener(MouseEvent.CLICK, playPause);
// Set up the onEnterFrame Event for EQ and other various things we may add later on
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event:Event):void {

	// ANIMATED EQ BARS CODE
    eqBarLeft1.gotoAndStop (Math.round(channel.leftPeak * 7) ); // 10 is the amount of frames in our EQbar clips
    eqBarRight1.gotoAndStop (Math.round(channel.rightPeak * 5) ); // 10 is the amount of frames in our EQbar clips
	eqBarLeft2.gotoAndStop (Math.round(channel.leftPeak * 6) ); // 10 is the amount of frames in our EQbar clips
    eqBarRight2.gotoAndStop (Math.round(channel.rightPeak * 7) ); // 10 is the amount of frames in our EQbar clips
	eqBarLeft3.gotoAndStop (Math.round(channel.leftPeak * 5) ); // 10 is the amount of frames in our EQbar clips
    eqBarRight3.gotoAndStop (Math.round(channel.rightPeak * 4) ); // 10 is the amount of frames in our EQbar clips
	eqBarLeft4.gotoAndStop (Math.round(channel.leftPeak * 6) ); // 10 is the amount of frames in our EQbar clips
    eqBarRight4.gotoAndStop (Math.round(channel.rightPeak * 5) ); // 10 is the amount of frames in our EQbar clips
	
	
    // Set and change volume if they drag
    var volumeLevel = channel.soundTransform;
	var newLevel:Number = (volumeSlider.knob.x) / -100;
	volumeLevel.volume = newLevel;
	channel.soundTransform = volumeLevel;
	volumeSlider.volumeLightBar.width = volumeSlider.knob.x;

	
}

I am using three frames to animate the eq while the sound is playing

Is This A Good Question/Topic? 0
  • +

Page 1 of 1