views:

1398

answers:

5

Hey.

Im working on a flash project where I am loading multiple sounds from external files. The problem is that when I play them within my project there is a small delay from when they should be played until they are actually playing.

My sounds are very short and are loaded before the project is actually using them. I have looked up the problem online and it looks like the problem is not something that is only happening for me. But, non of the resources I found had any clear ways of fixing this.

Some resources say that you can fix this my constantly having a sound playing in the background. I have that but it does not help. I have also looked at the actual sound file in a sound tool and there is a small delay before the sound starts, but it is very very small and should not result in the delay im seeing in my flash project.

Does anyone know of a good way to fix it?

+1  A: 

How noticeable is the delay? If this is a synchronization problem, are you open to maybe delaying the movie a very small amount until the sound starts playing? That way at least things will be in synch. If this is okay, read on:

How are you playing the sounds? If you are playing them via AS3, there is a simple way to check when a sound is fully loaded. Suppose your sound is called 'mySound'. Add an event listener to it which fires once the sound is fully loaded:

mySound.addEventListener(Event.COMPLETE,eventHandler);

Then, start playing your movie in the event handler:

function eventHandler(e:Event)
{
    play();
}

That way, your movie will only start playing once the sound has been loaded.

James Bound
I have already made sure that the sounds are loaded completely.
Ole
Then what's the problem?
James Bound
They are loaded correctly, but there is a small delay when it comes to playing them.
Ole
A: 

I had the same issue. Download the latest update for Flash CS4.... the sound problem has been fixed among other things. http://blogs.adobe.com/rgalvan/2009/05/flash%5Fcs4%5Fupdate%5Fnow%5Favailable.html hope it helps

politan
A: 

I think you are suffering from the silence that is added to the beginning of a sound by the MP3 codec. It adds whatever amount makes the compression work best for each file and can vary quite a bit. You need to open your MP3 files in an editor and measure the offset to the actual start of the sound and then provide that value to the play() method as the startTime.

david
A: 

Hi guys I had the same problem I had the delay before playing sond, the delay is of about 500ms, maybe 300. I tried wav files also but the same I tried to play swf from folder and the delay seem to be not anymore. It seems that the delay is present only when playing from CS4 program after compiling. If playing not from program, but opening swf file with an standalone player, the delay seem to be gone...

AlexG
A: 

Hello, i simply want to play a sound, let's say when 20% of the bytesTotal's are loaded. It works with the code bellow, but the sound his completely saturate! Here is my complete code

var s:Sound = new Sound(new URLRequest("http://music.oresort.fr/oceandrive-Some-People.mp3")); s.addEventListener( ProgressEvent.PROGRESS, currentlyLoading ); function currentlyLoading( sa:ProgressEvent ):void { var percent = int((sa.bytesLoaded*100) / sa.bytesTotal); if (percent == 20) { s.play(0, 1000); } }