- From: Chris Rogers <crogers@google.com>
- Date: Wed, 31 Oct 2012 10:41:02 -0700
- To: Jerome Etienne <jerome.etienne@gmail.com>
- Cc: public-audio@w3.org
Received on Wednesday, 31 October 2012 17:41:34 UTC
On Wed, Oct 31, 2012 at 4:39 AM, Jerome Etienne <jerome.etienne@gmail.com>wrote: > Hello, > > i would like to play multiple sounds (songs in mp3) one after the other. > Is there a way to detect the end of a playing sound ? an event endOfSound > or something like that ? > > Currently i storing the duration of the currently playing sound, do a > settimeout which is triggered after this time, when it is triggered, i stop > the current sound and start the new one... rather clumsy. is there a better > way ? > You should be able to schedule the new one to start at exactly the time when the old one ends - in other words seamless, gap-free playback. Since you know the start time of the first sound, and its duration, something like: sound1.start(time1); sound2.start(time1 + duration1); Of course, the second start call could be made immediately as in this example, or called at a later time, as long as it's before the first sound has finished. You could use a setTimeout() for that with a comfortable safety margin. > Jerome >
Received on Wednesday, 31 October 2012 17:41:34 UTC