Allow scanner to stop nicely when it runs out of files
This commit is contained in:
parent
89fe08a583
commit
21123e3cd9
@ -15,6 +15,7 @@ class Scanner(object):
|
||||
def __init__(self, files, callback):
|
||||
self.uris = [path_to_uri(abspath(f)) for f in files]
|
||||
self.callback = callback
|
||||
self.loop = gobject.MainLoop()
|
||||
|
||||
self.pipe = gst.element_factory_make('playbin2')
|
||||
|
||||
@ -24,8 +25,6 @@ class Scanner(object):
|
||||
|
||||
self.next_uri()
|
||||
|
||||
gobject.MainLoop().run()
|
||||
|
||||
def process_message(self, bus, message):
|
||||
data = message.parse_tag()
|
||||
self.callback(dict([(k, data[k]) for k in data.keys()]))
|
||||
@ -33,17 +32,14 @@ class Scanner(object):
|
||||
|
||||
def next_uri(self):
|
||||
if not self.uris:
|
||||
sys.exit(0)
|
||||
return self.stop()
|
||||
|
||||
self.pipe.set_state(gst.STATE_NULL)
|
||||
self.pipe.set_property('uri', self.uris.pop())
|
||||
self.pipe.set_state(gst.STATE_PAUSED)
|
||||
|
||||
def debug(data):
|
||||
print data
|
||||
def start(self):
|
||||
self.loop.run()
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) == 1:
|
||||
sys.exit(1)
|
||||
|
||||
Scanner(sys.argv[1:], debug)
|
||||
def stop(self):
|
||||
self.loop.quit()
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user