mp3play
mp3play copied to clipboard
OS X Support
Hello,
I've written my own module, playsound (currently on pypi) which allows you to play WAV files on Windows and Linux plus anything supported by QuickTime (WAV, MP3, and many others) on OS X.
Here's what the OS X portion of the code looks like:
def playsound_OSX(path, block = True):
from AppKit import NSSound
from time import sleep
sound = NSSound.alloc()
sound.initWithContentsOfFile_byReference_(path, True)
sound.play()
if block:
sleep(sound.duration())
AppKit is a standard part of Python on OS X - it's not included in any other OSs so you need to make sure this code is only run on OS X (I check if platform.system() == 'Darwin', personally.)