diff --git a/mopidy/scanner.py b/mopidy/scanner.py index 921d9272..aa562ff1 100644 --- a/mopidy/scanner.py +++ b/mopidy/scanner.py @@ -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() diff --git a/tests/data/blank.mp3 b/tests/data/blank.mp3 index 6aa48cd8..ef159a70 100644 Binary files a/tests/data/blank.mp3 and b/tests/data/blank.mp3 differ