X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a5dd1c33c8291e07e1f819f4b32aef521b5ed1f..e11d2abe46cee46100ac19ff00f018b21ae861fa:/wxPython/demo/Sound.py diff --git a/wxPython/demo/Sound.py b/wxPython/demo/Sound.py index c6d7028edb..871fdde068 100644 --- a/wxPython/demo/Sound.py +++ b/wxPython/demo/Sound.py @@ -9,7 +9,7 @@ class TestPanel(wx.Panel): def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.log = log - + b = wx.Button(self, -1, "Play Sound 1 (sync)", (25, 25)) self.Bind(wx.EVT_BUTTON, self.OnButton1, b) @@ -22,9 +22,9 @@ class TestPanel(wx.Panel): def OnButton1(self, evt): try: - sound = wx.Sound(opj('data/anykey.wav')) + self.sound = wx.Sound(opj('data/anykey.wav')) self.log.write("before Play...\n") - sound.Play(wx.SOUND_SYNC) + self.sound.Play(wx.SOUND_SYNC) self.log.write("...after Play\n") except NotImplementedError, v: wx.MessageBox(str(v), "Exception Message") @@ -32,11 +32,15 @@ class TestPanel(wx.Panel): def OnButton2(self, evt): try: - #sound = wx.Sound(opj('data/plan.wav')) - data = open(opj('data/plan.wav'), 'rb').read() - sound = wx.SoundFromData(data) + if True: + self.sound = wx.Sound(opj('data/plan.wav')) + else: + # sounds can also be loaded from a buffer object + data = open(opj('data/plan.wav'), 'rb').read() + self.sound = wx.SoundFromData(data) + self.log.write("before Play...\n") - sound.Play(wx.SOUND_ASYNC) + self.sound.Play(wx.SOUND_ASYNC) wx.YieldIfNeeded() self.log.write("...after Play\n") except NotImplementedError, v: @@ -50,12 +54,13 @@ class TestPanel(wx.Panel): style=wx.OPEN) if dlg.ShowModal() == wx.ID_OK: try: - sound = wx.Sound(dlg.GetPath()) - sound.Play() + #self.sound = wx.Sound(dlg.GetPath()) + #self.sound.Play() + wx.Sound.PlaySound(dlg.GetPath()) except NotImplementedError, v: wx.MessageBox(str(v), "Exception Message") dlg.Destroy() - + #---------------------------------------------------------------------- @@ -68,8 +73,8 @@ def runTest(frame, nb, log): overview = """

Sound

-This class represents a short wave file, in Windows WAV format, that can -be stored in memory and played. Currently this class is implemented on Windows +This class represents a short wave file, in Windows WAV format, that can +be stored in memory and played. Currently this class is implemented on Windows and GTK (Linux) only.

This demo offers two examples, both driven by buttons, but obviously the event