Page 254 -
P. 254
building a graphical user interface
Frank: I think sound is going to be a problem.
Jim: Sounds easy to me...
Joe & Frank: <groan>.
Jim: Sorry, couldn’t resist that one. Seriously, though, how hard can
it be to play a sound from a program? You actually can‛t
Joe: Playing a sound is not the problem; getting it to work on See... sound‛s “see” sound... but, don‛t
multiple platforms can be. For instance, what works on Windows the problem. worry, it‛ll be grand.
might not work on Mac OS X or Linux.
Jim: That’s not a problem. I only use Windows, so I’ll be OK.
Frank: Good for you, but the rest of us want to play, too, and we
don’t want to have to... um... eh... downgrade to Windows.
Jim: Typical: have a swipe at Windows when something doesn’t
work on your non-Windows computer.
Joe: Cool it, guys. We need to stop bickering and come up with a
solution that lets us play sounds and works on Windows, Mac OS X,
and Linux. And it has to work with Python, too.
Jim: You mean Python doesn’t support sound as standard?!?
Frank: No, not really. In fact, very few programming languages
support sound in a cross-platform way. This isn’t just a Python
problem.
Jim: So... we’re outta luck then. Does that mean it’s time to go
home?
Joe: Not so fast, Jim! I’m pretty sure pygame can help here.
Jim: So... I can’t go home early, but I can play games?
Frank: Seriously, Jim, I think Joe’s right. We can use pygame to
play our sounds in Python. Frank Joe
Jim: And it’ll work on Windows, Mac OS X, and Linux? Jim
Joe: Yes, I’m pretty sure it will. Granted, pygame’s a set of gaming
libraries for Python, but all we need to use is the bit that handles
playing sounds.
Jim: Sounds great. I can’t wait to see it in action.
Frank: Didn’t you mean “hear it in action”?
Jim & Joe: <groan>.
you are here 4 219