Client code converted to py3
This commit is contained in:
parent
61686b53ca
commit
bd448406b8
|
@ -2,13 +2,11 @@ import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
import dbus.mainloop.glib
|
import dbus.mainloop.glib
|
||||||
|
|
||||||
import dbus_smartobject
|
from . import dbus_smartobject
|
||||||
import event
|
from . import event
|
||||||
|
|
||||||
import __main__
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import gi
|
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
|
|
||||||
|
@ -18,7 +16,7 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
if not quickfolder is None:
|
if not quickfolder is None:
|
||||||
self._quickfolder = quickfolder
|
self._quickfolder = quickfolder
|
||||||
else:
|
else:
|
||||||
self._quickfolder = os.path.dirname(__main__.__file__)
|
self._quickfolder = os.path.dirname(os.getcwd())
|
||||||
|
|
||||||
self.Playing = False
|
self.Playing = False
|
||||||
self.Paused = False
|
self.Paused = False
|
||||||
|
@ -111,7 +109,7 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
self.status_position = self.Position()
|
self.status_position = self.Position()
|
||||||
#print "backed up position: {0}".format(self.status_position)
|
#print "backed up position: {0}".format(self.status_position)
|
||||||
|
|
||||||
GObject.timeout_add(1000, self.statusticker);
|
GObject.timeout_add(1000, self.statusticker)
|
||||||
|
|
||||||
#callback function
|
#callback function
|
||||||
def _onLoading(self,url):
|
def _onLoading(self,url):
|
||||||
|
@ -214,15 +212,15 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
path = os.path.join(self._quickfolder,file)
|
path = os.path.join(self._quickfolder,file)
|
||||||
|
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
path = os.path.join(os.path.dirname(__main__.__file__),file)
|
path = os.path.join(os.getcwd(),file)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if duration is None or duration <= 0:
|
if duration is None or duration <= 0:
|
||||||
self.call("QuickPlay",file)
|
self.call("QuickPlay",file)
|
||||||
else:
|
else:
|
||||||
self.call("QuickPlayFor",file,duration)
|
self.call("QuickPlayFor",file,duration)
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call QuickPlay function because of no connection"
|
print("Could not call QuickPlay function because of no connection")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def QuickPlayUrl(self, url, duration = None):
|
def QuickPlayUrl(self, url, duration = None):
|
||||||
|
@ -233,8 +231,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
self.call("QuickPlayUrl",url)
|
self.call("QuickPlayUrl",url)
|
||||||
else:
|
else:
|
||||||
self.call("QuickPlayUrlFor",url,duration)
|
self.call("QuickPlayUrlFor",url,duration)
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call QuickPlayUrl function because of no connection"
|
print("Could not call QuickPlayUrl function because of no connection")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def QuickLoop(self, file):
|
def QuickLoop(self, file):
|
||||||
|
@ -246,12 +244,12 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
path = os.path.join(self._quickfolder,file)
|
path = os.path.join(self._quickfolder,file)
|
||||||
|
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
path = os.path.join(os.path.dirname(__main__.__file__),file)
|
path = os.path.join(os.getcwd(),file)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.call("QuickLoop",file)
|
self.call("QuickLoop",file)
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call QuickPlay function because of no connection"
|
print("Could not call QuickPlay function because of no connection")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def QuickLoopUrl(self, url):
|
def QuickLoopUrl(self, url):
|
||||||
|
@ -259,8 +257,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.call("QuickLoopUrl",url)
|
self.call("QuickLoopUrl",url)
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call QuickPlayUrl function because of no connection"
|
print("Could not call QuickPlayUrl function because of no connection")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def LoadFile(self, file):
|
def LoadFile(self, file):
|
||||||
|
@ -268,8 +266,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.call("LoadFile",file)
|
self.call("LoadFile",file)
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call LoadFile because of no connection"
|
print("Could not call LoadFile because of no connection")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def LoadUrl(self, url):
|
def LoadUrl(self, url):
|
||||||
|
@ -277,8 +275,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.call("LoadUrl",url)
|
self.call("LoadUrl",url)
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call LoadUrl because of no connection"
|
print("Could not call LoadUrl because of no connection")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def PlayFor(self, duration):
|
def PlayFor(self, duration):
|
||||||
|
@ -286,8 +284,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.call("PlayFor",duration)
|
self.call("PlayFor",duration)
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call PlayFor because of no connection"
|
print("Could not call PlayFor because of no connection")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def Play(self):
|
def Play(self):
|
||||||
|
@ -295,8 +293,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.call("Play")
|
self.call("Play")
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call Play because of no connection"
|
print("Could not call Play because of no connection")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def Loop(self):
|
def Loop(self):
|
||||||
|
@ -304,8 +302,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.call("Loop")
|
self.call("Loop")
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call Loop because of no connection"
|
print("Could not call Loop because of no connection")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def Pause(self):
|
def Pause(self):
|
||||||
|
@ -313,8 +311,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.call("Pause")
|
self.call("Pause")
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call Pause because of no connection"
|
print("Could not call Pause because of no connection")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def Stop(self):
|
def Stop(self):
|
||||||
|
@ -322,8 +320,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.call("Stop")
|
self.call("Stop")
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call Stop because of no connection"
|
print("Could not call Stop because of no connection")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def Length(self):
|
def Length(self):
|
||||||
|
@ -331,8 +329,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return self.call("Length")
|
return self.call("Length")
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call Length because of no connection"
|
print("Could not call Length because of no connection")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def Position(self):
|
def Position(self):
|
||||||
|
@ -340,8 +338,8 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return self.call("Position")
|
return self.call("Position")
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call Position because of no connection"
|
print("Could not call Position because of no connection")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def Seek(self,position):
|
def Seek(self,position):
|
||||||
|
@ -351,7 +349,7 @@ class MediaClient(dbus_smartobject.DBusSmartObject):
|
||||||
self.call("Seek",position)
|
self.call("Seek",position)
|
||||||
self.status_position = position
|
self.status_position = position
|
||||||
|
|
||||||
except dbus_smartobject.NoConnectionError as x:
|
except dbus_smartobject.NoConnectionError:
|
||||||
print "Could not call because of no connection"
|
print("Could not call because of no connection")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
[DEFAULT]
|
[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
|
XS-Python-Version: >= 2.6
|
||||||
Section: sound
|
Section: sound
|
||||||
Package: mediaserver
|
Package: mediaserver
|
||||||
|
|
|
@ -29,11 +29,18 @@ class TestController:
|
||||||
|
|
||||||
GObject.timeout_add(10, self.tick)
|
GObject.timeout_add(10, self.tick)
|
||||||
|
|
||||||
|
GObject.timeout_add(90000, self.getPosition)
|
||||||
|
|
||||||
def tick(self):
|
def tick(self):
|
||||||
self.player.QuickPlay(sys.argv[1])
|
self.player.QuickPlay(sys.argv[1])
|
||||||
#GObject.timeout_add(3000, self.reboot)
|
#GObject.timeout_add(3000, self.reboot)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def getPosition(self):
|
||||||
|
pos = self.player.Position()
|
||||||
|
print("Position:")
|
||||||
|
print(pos)
|
||||||
|
|
||||||
def onStarting(self):
|
def onStarting(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user