Looping a streaming sound

hi,

i have no issues looping an event sound but I can’t seem to do it for a stream, my code…

mySound = new Sound();
mySound.loadSound(“music.mp3”,true);
_root.mySound.start(0,999);
mySound.setVolume (50)

when I change the ‘true’ to ‘false’ (event sound) it works fine.

help!!

…does nobody know how to make a streaming mp3 loop??

Hi victim,

Try this. Not sure whether this will work.


mySound = new Sound();
mySound.loadSound("music.mp3",true);
_root.mySound.start();
mySound.setVolume (50);
mySound.onSoundComplete = function(){
    _root.mySound.stop();
   _root.mySound.start();
}


thanks andrthad,

didn’t work, any other suggestions…

Hey victim,

Take a look at this thread…

http://flashkit.com/board/showthread.php?threadid=417501&highlight=loop+stream

It appears that this should work:


mySound = new Sound();
mySound.loadSound("music.mp3",true);
mySound.start();
mySound.setVolume (50);
mySound.onSoundComplete = function(){
       mySound.start(0,999);
}

nope, it plays once then stops.

fla is attached,

been following that thread, but none of the codes work either.

Hi victim,

You’re fla worked fine for me. See attached link.

http://www.thadandrews.com/untitled-1.swf

My example is not a perfect loop, but you can see it loops just fine. You might verify the following:

  1. Using Flash MX
  2. latest patch for Flash MX

http://www.macromedia.com/support/flash/downloads.html
3. Your mp3 is in the same folder as your published swf.

aahhh…

can’t access your link, just updated all quicktime software but still can’t open it, and other links i’ve tried.

i am using MX full version, all up to date players, plugins.

I must be doing something wrong.

step1.
open new fla…

step2
enter above code in first frame, scene1

step3
place ‘music.mp3’ in same folder as fla

step4
publish

result.
sound plays once and then stops.

IS THIS WRONG.

Man… I’m running out of ideas. I did the exact same thing you did when I got your fla.

Are you saying you can’t access this link through the web?
http://www.thadandrews.com/untitled-1.swf

You might try double checking your publish settings.

Are you Mac or PC?
What OS are you using?
What browser are you using?

when I enter your page i get the attached jpg on a whte screen…something with my QT software.

I’m on PC and using XP pro.

checked all publish settings…

Hmm…

I am on a PC and running Windows XP Pro as well. It has to be some configuration in your browser. What browser are you using? Can you view any flash website or do you get the same QT icon?

i can veiw everything fine,i have IE6 only thing i can’t veiw is your link and the guys link on Flashlink, ironically, regarding the same issue.

But i think i’ve found away around it, when i set the code to false instead of true, it plays and loops fine. now this would suggest the sound is now event, but it’s playing externally from the SWF and the file size of the Mp3 is not included in the SWF.

Which i see as doing the same thing as stream does.

what do you think about this method.

thanx.

hey, just tried this code to make mp3 kick in after 90 secs…

mySound = new Sound();
mySound.loadSound (“music.mp3”,true);
mySound.start (90,0);
mySound.setVolume(75);

didn’t work

then tried

mySound = new Sound();
mySound.loadSound (“music.mp3”,false);
mySound.start (90,0);
mySound.setVolume(75);

does this mean that mystream only activates on false instead of true for some reason, hence my problems…

You’re right about changing the stream parameter to false. It is just completely downloading the mp3 and then playing it.

So basically you can play a swf with an external mp3 if it the stream parameter is set to false, but not if it is set to true.

Do you see this same thing when publishing locally on your machine or only through the web?

Hey victim,

I haven’t really played around with the 1st parameter of the start(); function. Take a look at this.

mySound .start([ secondOffset , loop ])

Parameters
secondOffset An optional parameter that lets you start playing the sound at a specific point. For example, if you have a 30-second sound and want the sound to start playing in the middle, specify 15 for the secondOffset parameter. The sound is not delayed 15 seconds, but rather starts playing at the 15-second mark.

OK, so I’m on my way out find a bus to throw myself in front because I’m such an idiot.

I was only publishing in Flash and the stream (true) wouldn’t loop, but now I bring it into a browser and guess what…nuff said.

Thankyou andrthad for having so much patience.

I more thing i u know how to do it,

my mp3 is say 50secs long. what i want is another Mp3 to start at 40secs into the first one so they overlap. So basically 2 mp3 constantly overlapping.

thanx again

Hi victim,

Try this. Haven’t tested. At work with no Flash.


//
this.onLoad = function(){
   mySongList = new Array();
   mySongList = ["song1.mp3", "song2.mp3", "song3.mp3"]; 
   mySongNumber = 0;
   mySong = new Sound();
   mySong2 = new Sound();
   mySong.loadSound(mySongList[mySongNumber],true);
   mySong.start();
};

this.onEnterFrame = function(){
   if(mySong.duration - (10 * 1000) == mySong.position && mySong.position > 2000){
       if(mySongNumber == mySongList.length - 1){
               mySongNumber = 0;
       }else{
               mySongNumber++;
       }
       mySong2.loadSound(mySongList[mySongNumber],true);
       mySong2.start();
   }
   if(mySong2.duration - (10 * 1000) == mySong2.position && mySong2.position > 2000){
       if(mySongNumber == mySongList.length - 1){
               mySongNumber = 0;
       }else{
               mySongNumber++;
       }
       mySong.loadSound(mySongList[mySongNumber],true);
       mySong.start();
   }
};