1
from threading import Thread
6
class RepeatSound(Thread):
7
def __init__(self, howmanytimes, button, volume, PlayerInstance):
14
self.times = howmanytimes - 1
15
self.bus = PlayerInstance.get_bus()
16
self.bus.add_signal_watch()
17
self.bus.connect('message', self.BusMessage)
18
self.time_format = gst.Format(gst.FORMAT_TIME)
21
self.volume = volume / 100
22
self.PlayerInstance = PlayerInstance
26
self.PlayerInstance.set_property("volume", self.volume)
27
self.PlayerInstance.set_state(gst.STATE_PLAYING)
30
while self.Repeated < self.times and \
31
self.PlayerInstance.get_state()[1] != gst.STATE_NULL:
37
while self.PlayerInstance.get_state()[1] != gst.STATE_NULL: continue
39
self.PlayerInstance.set_property("volume", 0)
40
self.PlayerInstance.set_state(gst.STATE_NULL)
43
gtk.gdk.threads_enter()
44
self.button.set_sensitive(False)
45
gtk.gdk.threads_leave()
47
def BusMessage(self, Bus, Message):
48
if Message.type == gst.MESSAGE_EOS:
49
self.PlayerInstance.set_state(gst.STATE_PAUSED)
50
self.PlayerInstance.seek_simple(self.time_format, gst.SEEK_FLAG_FLUSH, 0)
51
self.PlayerInstance.set_property("volume", self.volume)
52
self.PlayerInstance.set_state(gst.STATE_PLAYING)