Sound question: notification at end of play

Lex Spoon lex at cc.gatech.edu
Thu Mar 7 17:30:08 UTC 2002


olmeca at netscape.net (Rudi Angela) wrote:
> Hi there,
> Is there a way I can have my object notified when a sound has finished playing?
> I'm playing mp3 files as part of a presentation. When the  playing is done the presentation should continue to the next 'slide'.
> I've tried adding making my object dependent on the sound and sending a changed: message to the sound in SoundPlayer playLoop, but it doesn't work.
> Any ideas, suggestions?


The easiest thing would be to check in a #step method.

You can do this with the etoy system, by the way.  EToys is fabulous for
presentations.  You can make a script watch the progress bar of an
MPEGPlayer, and then do something when the progress bar reaches its
maximum.  I believe MPEGPlayer can be made to work with other sounds,
too.

I've posted an example as ChangeOnSoundEnd on Bob's SuperSwiki.  It was
made in Squeak 3.2.  The only awkward part is the actual switch to a new
project.  Is there an easy way to do this in EToys?


By the way, one issue with your nice idea of doing #changed: from
SoundPlayer is that the #changed: (and the #update:) will be sent from
the sound-player thread, not the UI thread.


-Lex



More information about the Squeak-dev mailing list