Minor bugfixes
This commit is contained in:
parent
8cfa5c712e
commit
61686b53ca
|
@ -69,7 +69,7 @@ class BasicPlayer(GObject.GObject):
|
|||
|
||||
def do_set_property(self, property, value):
|
||||
if property.name == 'volume':
|
||||
volume = clamp(value,0.0,1.0)
|
||||
volume = value if value >= 0.0 and value <= 1.0 else (0.0 if value < 0 else 1.0)
|
||||
self.pipeline.set_property('volume', volume)
|
||||
#print("Set volume to {0}, got {1}".format(volume,self.pipeline.get_property('volume')))
|
||||
self.emit('volume-changed',volume)
|
||||
|
@ -158,8 +158,8 @@ class BasicPlayer(GObject.GObject):
|
|||
self.pipeline.get_bus().disconnect(self.busconnection)
|
||||
self.pipeline.get_bus().remove_signal_watch()
|
||||
self.pipeline.set_state(Gst.State.NULL)
|
||||
except GObject.GError as e:
|
||||
self.set_sensitive(True)
|
||||
except GObject.GError:
|
||||
pass
|
||||
|
||||
def seek(self,seconds):
|
||||
self.pipeline.seek_simple(Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT, seconds* Gst.SECOND)
|
||||
|
@ -204,7 +204,8 @@ class BasicPlayer(GObject.GObject):
|
|||
pass
|
||||
elif t == Gst.MessageType.STREAM_STATUS:
|
||||
(status,owner) = message.parse_stream_status()
|
||||
# print("Stream status: {0} (by {1})\n".format(status,owner))
|
||||
if False:
|
||||
print("Stream status: {0} (by {1})\n".format(status,owner))
|
||||
pass
|
||||
elif t == Gst.MessageType.BUFFERING:
|
||||
pct = message.parse_buffering()
|
||||
|
@ -225,7 +226,8 @@ class BasicPlayer(GObject.GObject):
|
|||
if message.src == self.pipeline:
|
||||
(old,new,pending) = message.parse_state_changed()
|
||||
self.pipeline_state = new
|
||||
# print("State changed from '{0}' to '{1}' pending '{2}'\n".format(old,new,pending))
|
||||
if False:
|
||||
print("State changed from '{0}' to '{1}' pending '{2}'\n".format(old,new,pending))
|
||||
if old == Gst.State.READY and new == Gst.State.PAUSED and self.player_state == "LOADING":
|
||||
self.pipeline.set_state(Gst.State.PAUSED)
|
||||
self.player_state = "READY"
|
||||
|
|
|
@ -69,6 +69,7 @@ class MediaService(dbus.service.Object):
|
|||
self.quickplayduration = 0
|
||||
self.quickplayloop = False
|
||||
|
||||
def Start(self):
|
||||
self.window.show()
|
||||
self.tick()
|
||||
|
||||
|
@ -167,35 +168,35 @@ class MediaService(dbus.service.Object):
|
|||
# self.quickplayer.playfor(file,duration)
|
||||
|
||||
@dbus.service.method(dbus_interface='nl.miqra.MediaCore.Media', in_signature='s', out_signature='')
|
||||
def QuickPlayUrl(self, url,):
|
||||
def QuickPlayUrl(self, url):
|
||||
""" Directly play back a url
|
||||
"""
|
||||
if self.loadcount < self.loadmax:
|
||||
print("Quickplaying file {0}".format(file))
|
||||
print("Quickplaying url {0}".format(url))
|
||||
self.quickplay = True
|
||||
self.quickplayduration = 0
|
||||
self.quickplayloop = False
|
||||
self.player.load_uri(file)
|
||||
self.player.load_uri(url)
|
||||
self.loadcount += 1
|
||||
else:
|
||||
print("Skipping load of file {0} because maximum simultaneous loads ({1}) was reached. Wait until ready....".format(file,self.loadmax))
|
||||
print("Skipping load of file {0} because maximum simultaneous loads ({1}) was reached. Wait until ready....".format(url,self.loadmax))
|
||||
|
||||
@dbus.service.method(dbus_interface='nl.miqra.MediaCore.Media', in_signature='sd', out_signature='')
|
||||
def QuickPlayUrlFor(self, url, duration):
|
||||
""" Directly play back a url
|
||||
"""
|
||||
if self.loadcount < self.loadmax:
|
||||
print("Quickplaying file {0} for {1} seconds".format(file,duration))
|
||||
print("Quickplaying url {0} for {1} seconds".format(url,duration))
|
||||
self.quickplay = True
|
||||
self.quickplayduration = duration
|
||||
self.quickplayloop = False
|
||||
self.player.load_uri(file)
|
||||
self.player.load_uri(url)
|
||||
self.loadcount += 1
|
||||
else:
|
||||
print("Skipping load of file {0} because maximum simultaneous loads ({1}) was reached. Wait until ready....".format(file,self.loadmax))
|
||||
print("Skipping load of file {0} because maximum simultaneous loads ({1}) was reached. Wait until ready....".format(url,self.loadmax))
|
||||
|
||||
@dbus.service.method(dbus_interface='nl.miqra.MediaCore.Media', in_signature='s', out_signature='')
|
||||
def QuickLoop(self, file,):
|
||||
def QuickLoop(self, file):
|
||||
""" Directly play back a url
|
||||
"""
|
||||
if self.loadcount < self.loadmax:
|
||||
|
@ -209,18 +210,18 @@ class MediaService(dbus.service.Object):
|
|||
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 QuickLoopUrl(self, url,):
|
||||
def QuickLoopUrl(self, url):
|
||||
""" Directly play back a url
|
||||
"""
|
||||
if self.loadcount < self.loadmax:
|
||||
print("Quickplaying url {0}".format(uri))
|
||||
print("Quickplaying url {0}".format(url))
|
||||
self.quickplay = True
|
||||
self.quickplayduration = 0
|
||||
self.quickplayloop = True
|
||||
self.player.load_uri(url)
|
||||
self.loadcount += 1
|
||||
else:
|
||||
print("Skipping load of file {0} because maximum simultaneous loads ({1}) was reached. Wait until ready....".format(file,self.loadmax))
|
||||
print("Skipping load of file {0} because maximum simultaneous loads ({1}) was reached. Wait until ready....".format(url,self.loadmax))
|
||||
|
||||
|
||||
|
||||
|
@ -246,7 +247,7 @@ class MediaService(dbus.service.Object):
|
|||
print("Loading url {0}".format(uri))
|
||||
self.quickplay = False
|
||||
self.player.load_uri(uri)
|
||||
self.loadcount += 1;
|
||||
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))
|
||||
|
@ -444,8 +445,8 @@ def Run():
|
|||
os.environ['XDG_RUNTIME_DIR'] = "/run/user/{0}".format(os.getuid())
|
||||
|
||||
mediaservice = MediaService()
|
||||
mediaservice.Start()
|
||||
loop = GObject.MainLoop()
|
||||
loopcontext = loop.get_context()
|
||||
|
||||
|
||||
def onsigint(signal,frame):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import gi
|
||||
gi.require_version('Gst','1.0')
|
||||
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GObject, Gst
|
||||
|
||||
from threading import Thread
|
||||
import time
|
||||
|
@ -65,7 +65,7 @@ class MonitoredPlayer(BasicPlayer):
|
|||
self.looping = True
|
||||
if self.player_state != "PAUSED":
|
||||
self.startpos = 0
|
||||
self.playtime = -1;
|
||||
self.playtime = -1
|
||||
BasicPlayer.play(self)
|
||||
|
||||
|
||||
|
@ -73,11 +73,11 @@ class MonitoredPlayer(BasicPlayer):
|
|||
self.looping = False
|
||||
if self.player_state != "PAUSED":
|
||||
self.startpos = 0
|
||||
self.playtime = -1;
|
||||
self.playtime = -1
|
||||
BasicPlayer.play(self)
|
||||
|
||||
def stop(self):
|
||||
self.playtime = -1;
|
||||
self.playtime = -1
|
||||
BasicPlayer.stop(self)
|
||||
#self.monitor.stop()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user