From acc3ec8f2bf19238f9302fd81a06ad65b580a898 Mon Sep 17 00:00:00 2001 From: pmk Date: Mon, 24 Sep 2018 20:25:09 +0200 Subject: [PATCH] Integrated updates from sailplayer --- mediaserver/mediaserver.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/mediaserver/mediaserver.py b/mediaserver/mediaserver.py index 2930752..7c87f49 100644 --- a/mediaserver/mediaserver.py +++ b/mediaserver/mediaserver.py @@ -32,7 +32,7 @@ from quickplayer import QuickPlayer class MediaService(dbus.service.Object): def __init__(self): - + bus_name = dbus.service.BusName('nl.miqra.MediaCore.Media', bus=dbus.SystemBus()) dbus.service.Object.__init__(self, bus_name, '/nl/miqra/MediaCore/Media') @@ -48,6 +48,9 @@ class MediaService(dbus.service.Object): self.player.connect('volume-changed',self.onPlayerVolumeChanged) # parameters: volume self.player.connect('playback-buffering',self.onPlayerBuffering) # parameters: volume + self.loadcount = 0; + self.loadmax = 1; + @dbus.service.method(dbus_interface='nl.miqra.MediaCore.Media', in_signature='s', out_signature='') def QuickPlay(self, file,): """ Directly play back a local file @@ -77,18 +80,27 @@ class MediaService(dbus.service.Object): def LoadFile(self, file): """ Load a local file for playback """ - print "Loading file {0}".format(file) - self.player.load(file) - self.OnLoading("file://{0}".format(file)) + if self.loadcount < self.loadmax: + print "Loading file {0}".format(file) + print file + self.player.load(file) + self.loadcount += 1; + self.OnLoading("file://{0}".format(file)) + else: + print "Skipping load of file {0} because maximum simultaneous loads ({1}) was reached. Wait until ready....".format(file,self.loadmax); @dbus.service.method(dbus_interface='nl.miqra.MediaCore.Media', in_signature='s', out_signature='') def LoadUrl(self, uri): """ Load an url for playback """ - print "Loading url {0}".format(file) - self.player.load_uri(uri) - self.OnLoading(uri) - + if self.loadcount < self.loadmax: + print "Loading url {0}".format(uri) + self.player.load_uri(uri) + self.loadcount += 1; + self.OnLoading(uri) + else: + print "Skipping load of url {0} because maximum simultaneous loads ({1}) was reached. Wait until ready....".format(uri,self.loadmax); + @dbus.service.method(dbus_interface='nl.miqra.MediaCore.Media', in_signature='d', out_signature='') def PlayFor(self, duration): """ Starts playback for [duration] seconds @@ -147,6 +159,11 @@ class MediaService(dbus.service.Object): print " {0}: {1}".format(tag,taglist[tag]) except Exception as x: print "Error converting value for '{0}':\n {1}".format(tag,x) + + # reset load counter + self.loadcount = 0; + + # signal ready self.OnReady(filename,taglist) def onPlayerPlaying(self,player):