/usr/share/pyshared/PythonCard/sound.py is in python-pythoncard 0.8.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | """
__version__ = "$Revision: 1.7 $"
__date__ = "$Date: 2005/09/18 03:59:21 $"
"""
import wx
import sndhdr
class SoundFileError(Exception):
pass
class Sound:
"""
Feeble beginnings of a class for playing sounds.
The goal is to be able to provide a filename and then be able
to play the sound without worrying about sound formats or particular
OS capabilities. I haven't investigated the Python Standard Libraries
much yet.
"""
def __init__(self, filename) :
self._filename = filename
self._sndType = sndhdr.what(filename)
if self._sndType:
self._sndType = self._sndType[0]
if self._sndType in ['wav']:
try:
self._sound = wx.Sound(filename) # support resources?
except:
self._sndType = None
else:
self._sndType = None
if not self._sndType:
raise SoundFileError, 'This is not a valid sound file'
def play(self, async=True, looped=False) :
if self._sndType:
if async:
if looped:
flags = wx.SOUND_ASYNC | wx.SOUND_LOOP
else:
flags = wx.SOUND_ASYNC
else:
flags = wx.SOUND_SYNC
self._sound.Play(flags)
def stop(self):
if self._sndType:
self._sound.Stop()
|