Integrated updates from sailplayer

This commit is contained in:
pmk 2018-09-24 20:25:09 +02:00
parent 969d27b98e
commit acc3ec8f2b

View File

@ -32,7 +32,7 @@ from quickplayer import QuickPlayer
class MediaService(dbus.service.Object): class MediaService(dbus.service.Object):
def __init__(self): def __init__(self):
bus_name = dbus.service.BusName('nl.miqra.MediaCore.Media', bus=dbus.SystemBus()) bus_name = dbus.service.BusName('nl.miqra.MediaCore.Media', bus=dbus.SystemBus())
dbus.service.Object.__init__(self, bus_name, '/nl/miqra/MediaCore/Media') 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('volume-changed',self.onPlayerVolumeChanged) # parameters: volume
self.player.connect('playback-buffering',self.onPlayerBuffering) # 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='') @dbus.service.method(dbus_interface='nl.miqra.MediaCore.Media', in_signature='s', out_signature='')
def QuickPlay(self, file,): def QuickPlay(self, file,):
""" Directly play back a local file """ Directly play back a local file
@ -77,18 +80,27 @@ class MediaService(dbus.service.Object):
def LoadFile(self, file): def LoadFile(self, file):
""" Load a local file for playback """ Load a local file for playback
""" """
print "Loading file {0}".format(file) if self.loadcount < self.loadmax:
self.player.load(file) print "Loading file {0}".format(file)
self.OnLoading("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='') @dbus.service.method(dbus_interface='nl.miqra.MediaCore.Media', in_signature='s', out_signature='')
def LoadUrl(self, uri): def LoadUrl(self, uri):
""" Load an url for playback """ Load an url for playback
""" """
print "Loading url {0}".format(file) if self.loadcount < self.loadmax:
self.player.load_uri(uri) print "Loading url {0}".format(uri)
self.OnLoading(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='') @dbus.service.method(dbus_interface='nl.miqra.MediaCore.Media', in_signature='d', out_signature='')
def PlayFor(self, duration): def PlayFor(self, duration):
""" Starts playback for [duration] seconds """ Starts playback for [duration] seconds
@ -147,6 +159,11 @@ class MediaService(dbus.service.Object):
print " {0}: {1}".format(tag,taglist[tag]) print " {0}: {1}".format(tag,taglist[tag])
except Exception as x: except Exception as x:
print "Error converting value for '{0}':\n {1}".format(tag,x) print "Error converting value for '{0}':\n {1}".format(tag,x)
# reset load counter
self.loadcount = 0;
# signal ready
self.OnReady(filename,taglist) self.OnReady(filename,taglist)
def onPlayerPlaying(self,player): def onPlayerPlaying(self,player):