Client code converted to py3

This commit is contained in:
P.M. Kuipers 2021-05-15 14:26:35 +02:00
parent 61686b53ca
commit bd448406b8
3 changed files with 43 additions and 38 deletions

View File

@ -2,13 +2,11 @@ import dbus
import dbus.service
import dbus.mainloop.glib
import dbus_smartobject
import event
from . import dbus_smartobject
from . import event
import __main__
import os
import gi
from gi.repository import GLib
from gi.repository import GObject
@ -18,7 +16,7 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
if not quickfolder is None:
self._quickfolder = quickfolder
else:
self._quickfolder = os.path.dirname(__main__.__file__)
self._quickfolder = os.path.dirname(os.getcwd())
self.Playing = False
self.Paused = False
@ -111,7 +109,7 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
self.status_position = self.Position()
#print "backed up position: {0}".format(self.status_position)
GObject.timeout_add(1000, self.statusticker);
GObject.timeout_add(1000, self.statusticker)
#callback function
def _onLoading(self,url):
@ -214,15 +212,15 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
path = os.path.join(self._quickfolder,file)
if not os.path.isfile(path):
path = os.path.join(os.path.dirname(__main__.__file__),file)
path = os.path.join(os.getcwd(),file)
try:
if duration is None or duration <= 0:
self.call("QuickPlay",file)
else:
self.call("QuickPlayFor",file,duration)
except dbus_smartobject.NoConnectionError as x:
print "Could not call QuickPlay function because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call QuickPlay function because of no connection")
pass
def QuickPlayUrl(self, url, duration = None):
@ -233,8 +231,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
self.call("QuickPlayUrl",url)
else:
self.call("QuickPlayUrlFor",url,duration)
except dbus_smartobject.NoConnectionError as x:
print "Could not call QuickPlayUrl function because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call QuickPlayUrl function because of no connection")
pass
def QuickLoop(self, file):
@ -246,12 +244,12 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
path = os.path.join(self._quickfolder,file)
if not os.path.isfile(path):
path = os.path.join(os.path.dirname(__main__.__file__),file)
path = os.path.join(os.getcwd(),file)
try:
self.call("QuickLoop",file)
except dbus_smartobject.NoConnectionError as x:
print "Could not call QuickPlay function because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call QuickPlay function because of no connection")
pass
def QuickLoopUrl(self, url):
@ -259,8 +257,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
"""
try:
self.call("QuickLoopUrl",url)
except dbus_smartobject.NoConnectionError as x:
print "Could not call QuickPlayUrl function because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call QuickPlayUrl function because of no connection")
pass
def LoadFile(self, file):
@ -268,8 +266,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
"""
try:
self.call("LoadFile",file)
except dbus_smartobject.NoConnectionError as x:
print "Could not call LoadFile because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call LoadFile because of no connection")
pass
def LoadUrl(self, url):
@ -277,8 +275,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
"""
try:
self.call("LoadUrl",url)
except dbus_smartobject.NoConnectionError as x:
print "Could not call LoadUrl because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call LoadUrl because of no connection")
pass
def PlayFor(self, duration):
@ -286,8 +284,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
"""
try:
self.call("PlayFor",duration)
except dbus_smartobject.NoConnectionError as x:
print "Could not call PlayFor because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call PlayFor because of no connection")
pass
def Play(self):
@ -295,8 +293,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
"""
try:
self.call("Play")
except dbus_smartobject.NoConnectionError as x:
print "Could not call Play because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call Play because of no connection")
pass
def Loop(self):
@ -304,8 +302,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
"""
try:
self.call("Loop")
except dbus_smartobject.NoConnectionError as x:
print "Could not call Loop because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call Loop because of no connection")
pass
def Pause(self):
@ -313,8 +311,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
"""
try:
self.call("Pause")
except dbus_smartobject.NoConnectionError as x:
print "Could not call Pause because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call Pause because of no connection")
pass
def Stop(self):
@ -322,8 +320,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
"""
try:
self.call("Stop")
except dbus_smartobject.NoConnectionError as x:
print "Could not call Stop because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call Stop because of no connection")
pass
def Length(self):
@ -331,8 +329,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
"""
try:
return self.call("Length")
except dbus_smartobject.NoConnectionError as x:
print "Could not call Length because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call Length because of no connection")
return 0
def Position(self):
@ -340,8 +338,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
"""
try:
return self.call("Position")
except dbus_smartobject.NoConnectionError as x:
print "Could not call Position because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call Position because of no connection")
return 0
def Seek(self,position):
@ -351,7 +349,7 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
self.call("Seek",position)
self.status_position = position
except dbus_smartobject.NoConnectionError as x:
print "Could not call because of no connection"
except dbus_smartobject.NoConnectionError:
print("Could not call because of no connection")
pass

View File

@ -1,6 +1,6 @@
[DEFAULT]
Depends: python-dbus, python-gi, gir1.2-gstreamer-1.0, gir1.2-gst-plugins-base-1.0, gstreamer1.0-plugins-good, gstreamer1.0-plugins-ugly, gstreamer1.0-plugins-bad, gstreamer1.0-alsa, gstreamer1.0-omx, gstreamer1.0-libav
Depends: python3-dbus, python3-gi, gir1.2-gstreamer-1.0, gstreamer1.0-gtk3, gir1.2-gst-plugins-base-1.0, gstreamer1.0-plugins-good, gstreamer1.0-plugins-ugly, gstreamer1.0-plugins-bad, gstreamer1.0-alsa, gstreamer1.0-x
XS-Python-Version: >= 2.6
Section: sound
Package: mediaserver

View File

@ -29,11 +29,18 @@ class TestController:
GObject.timeout_add(10, self.tick)
GObject.timeout_add(90000, self.getPosition)
def tick(self):
self.player.QuickPlay(sys.argv[1])
#GObject.timeout_add(3000, self.reboot)
pass
def getPosition(self):
pos = self.player.Position()
print("Position:")
print(pos)
def onStarting(self):
pass