I find a strange phenomenon that happened to me, I want to play sound when
press button, it works when I write as follows
@self.window.event
def on_key_press(symbol,modifiers):
soundtrack = pyglet.resource.media('choice.wav')
soundtrack.play()
however, if I write like this,
self.soundtrack = pyglet.resource.media('choice.wav')
@self.window.event
def on_key_press(symbol,modifiers):
self.soundtrack.play()
It raise errors,why?
C:\Python27\python.exe H:/cryptogram/cryptogram.py
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 314, in 'calling callback function'
File "H:\cryptogram\pyglet\window\win32\__init__.py", line 619, in f
result = event_handler(msg, wParam, lParam)
File "H:\cryptogram\pyglet\window\win32\__init__.py", line 690, in _event_key
self.dispatch_event(ev, symbol, modifiers)
File "H:\cryptogram\pyglet\window\__init__.py", line 1212, in dispatch_event
if EventDispatcher.dispatch_event(self, *args) != False:
File "H:\cryptogram\pyglet\event.py", line 357, in dispatch_event
if handler(*args):
File "H:\cryptogram\data\states\menu.py", line 42, in on_key_press
self.soundtrack.play()
File "H:\cryptogram\pyglet\media\sources\base.py", line 269, in play
player.queue(self)
File "H:\cryptogram\pyglet\media\player.py", line 88, in queue
group.queue(source)
File "H:\cryptogram\pyglet\media\sources\base.py", line 496, in queue
source = source._get_queue_source()
File "H:\cryptogram\pyglet\media\sources\base.py", line 377, in
_get_queue_source
raise MediaException('This source is already queued on a player.')
pyglet.media.exceptions.MediaException: This source is already queued on a
player.
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.