Play a Sound

Previous pageNext page

"Play a sound twice (you can substitute the path of any .wav file or just get the default sound)"

(Sound fromFile: '\Windows\Media\TaDa.wav')




Evaluate the above expression to create a Sound object from a .WAV file and then play it twice using the #woofAndWait message. Because the expression is laid out over three lines that all need to be evaluated at once, you should select them all before choosing Evaluate It (Ctrl+E).

One interesting point here is the use of the semicolon to "cascade" one message after another to the first object in the expression (in this case, the sound). Without the semicolon, the Smalltalk compiler would actually send the second #woofAndWait message to the result of the first one, rather than to the original sound object.

What's this "woof" business? Well, back in the early days when Dolphin was being created, the designers were younger and more frivolous. We just thought it would be amusing to make the message that caused a Sound to play itself be #woof or #woofAndWait. After that, I'm afraid it's just stuck.

Remember, to get back to these experiments just choose Help/First Splash in any Dolphin tool window.