<div dir="ltr"><span style="color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-height:17.804800033569336px">I am using gstreamer with python to play some music and need to trigger an event when playback has finished. I have tried this using the method provided in the tutorial but it simply does nothing when the track finishes. Here is the code I'm using:</span><br>
<div><span style="color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-height:17.804800033569336px"><br></span></div><div><span style="color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-height:17.804800033569336px"><div>
class Slave(object):</div><div> """Provides methods for playback on slave devices"""</div><div> def __init__(self):</div><div> self.playlist = []</div><div> self.playlist_index = 0</div>
<div> self.playlist_length = 0</div><div> self.player = gst.element_factory_make('playbin2', 'player')</div><div> fakesink = gst.element_factory_make('fakesink', 'fakesink')</div>
<div>
self.player.set_property('video-sink', fakesink)</div><div> bus = self.player.get_bus()</div><div> bus.add_signal_watch()</div><div> bus.connect('message', self.on_message)</div><div> </div>
<div> def play_list(self, playlist):</div><div> """Starts playing the playlist provided"""</div><div> self.playlist = playlist</div><div> self.playlist_index = 0</div><div> self.playlist_length = len(self.playlist)</div>
<div> self.player.set_property('uri', self.playlist[self.playlist_index])</div><div> self.player.set_state(gst.STATE_PLAYING)</div><div><br></div><div><div>def on_message(self, bus, message):</div><div> t = message.type</div>
<div> if t == gst.MESSAGE_EOS:</div><div> self.skip_forward()</div><div> elif t == gst.MESSAGE_ERROR:</div><div> self.skip_forward()</div><div> #TODO: Log this</div></div><div><br></div><div>Either I'm doing something wrong or there's a bug somewhere. Anyone got any ideas?<br>
</div></span></div></div>