Hold on to the Sound objects as the Mac async plays will stop when the
object is destroyed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28374 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
e586e41df3
commit
7ac36741b1
@ -22,9 +22,9 @@ class TestPanel(wx.Panel):
|
|||||||
|
|
||||||
def OnButton1(self, evt):
|
def OnButton1(self, evt):
|
||||||
try:
|
try:
|
||||||
sound = wx.Sound(opj('data/anykey.wav'))
|
self.sound = wx.Sound(opj('data/anykey.wav'))
|
||||||
self.log.write("before Play...\n")
|
self.log.write("before Play...\n")
|
||||||
sound.Play(wx.SOUND_SYNC)
|
self.sound.Play(wx.SOUND_SYNC)
|
||||||
self.log.write("...after Play\n")
|
self.log.write("...after Play\n")
|
||||||
except NotImplementedError, v:
|
except NotImplementedError, v:
|
||||||
wx.MessageBox(str(v), "Exception Message")
|
wx.MessageBox(str(v), "Exception Message")
|
||||||
@ -33,14 +33,14 @@ class TestPanel(wx.Panel):
|
|||||||
def OnButton2(self, evt):
|
def OnButton2(self, evt):
|
||||||
try:
|
try:
|
||||||
if True:
|
if True:
|
||||||
sound = wx.Sound(opj('data/plan.wav'))
|
self.sound = wx.Sound(opj('data/plan.wav'))
|
||||||
else:
|
else:
|
||||||
# sounds can also be loaded from a buffer object
|
# sounds can also be loaded from a buffer object
|
||||||
data = open(opj('data/plan.wav'), 'rb').read()
|
data = open(opj('data/plan.wav'), 'rb').read()
|
||||||
sound = wx.SoundFromData(data)
|
self.sound = wx.SoundFromData(data)
|
||||||
|
|
||||||
self.log.write("before Play...\n")
|
self.log.write("before Play...\n")
|
||||||
sound.Play(wx.SOUND_ASYNC)
|
self.sound.Play(wx.SOUND_ASYNC)
|
||||||
wx.YieldIfNeeded()
|
wx.YieldIfNeeded()
|
||||||
self.log.write("...after Play\n")
|
self.log.write("...after Play\n")
|
||||||
except NotImplementedError, v:
|
except NotImplementedError, v:
|
||||||
@ -54,8 +54,9 @@ class TestPanel(wx.Panel):
|
|||||||
style=wx.OPEN)
|
style=wx.OPEN)
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
try:
|
try:
|
||||||
sound = wx.Sound(dlg.GetPath())
|
#self.sound = wx.Sound(dlg.GetPath())
|
||||||
sound.Play()
|
#self.sound.Play()
|
||||||
|
wx.Sound.PlaySound(dlg.GetPath())
|
||||||
except NotImplementedError, v:
|
except NotImplementedError, v:
|
||||||
wx.MessageBox(str(v), "Exception Message")
|
wx.MessageBox(str(v), "Exception Message")
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
Loading…
Reference in New Issue
Block a user