No longer have to hold a reference to the sound object
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28397 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -22,9 +22,9 @@ class TestPanel(wx.Panel):
|
|||||||
|
|
||||||
def OnButton1(self, evt):
|
def OnButton1(self, evt):
|
||||||
try:
|
try:
|
||||||
self.sound = wx.Sound(opj('data/anykey.wav'))
|
sound = wx.Sound(opj('data/anykey.wav'))
|
||||||
self.log.write("before Play...\n")
|
self.log.write("before Play...\n")
|
||||||
self.sound.Play(wx.SOUND_SYNC)
|
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:
|
||||||
self.sound = wx.Sound(opj('data/plan.wav'))
|
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()
|
||||||
self.sound = wx.SoundFromData(data)
|
sound = wx.SoundFromData(data)
|
||||||
|
|
||||||
self.log.write("before Play...\n")
|
self.log.write("before Play...\n")
|
||||||
self.sound.Play(wx.SOUND_ASYNC)
|
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,9 +54,12 @@ class TestPanel(wx.Panel):
|
|||||||
style=wx.OPEN)
|
style=wx.OPEN)
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
try:
|
try:
|
||||||
#self.sound = wx.Sound(dlg.GetPath())
|
#sound = wx.Sound(dlg.GetPath())
|
||||||
#self.sound.Play()
|
#sound.Play()
|
||||||
|
|
||||||
|
# another way to do it.
|
||||||
wx.Sound.PlaySound(dlg.GetPath())
|
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()
|
||||||
|
Reference in New Issue
Block a user