2018-09-26 21:14:21 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
from mediaserver.client import MediaClient
|
|
|
|
|
|
|
|
#!/usr/bin/env python
|
|
|
|
import sys, os, glob
|
|
|
|
import signal
|
|
|
|
|
|
|
|
import gi
|
|
|
|
from gi.repository import GLib
|
|
|
|
from gi.repository import GObject
|
|
|
|
|
|
|
|
|
|
|
|
#import Resources
|
|
|
|
|
|
|
|
class TestController:
|
|
|
|
def __init__(self):
|
|
|
|
#initialize loop
|
|
|
|
self.mainloop = GLib.MainLoop() # main loop
|
|
|
|
#initialize sensing
|
|
|
|
self.player = MediaClient()
|
|
|
|
self.player.OnPlaying += self.onPlayerPlaying
|
|
|
|
self.player.OnStopped += self.onPlayerStopped
|
|
|
|
self.player.OnPaused += self.onPlayerPaused
|
|
|
|
self.player.OnFinished += self.onPlayerFinished
|
|
|
|
self.player.OnFinishing += self.onPlayerFinishing
|
|
|
|
self.player.OnLoading += self.onPlayerLoading
|
|
|
|
self.player.OnReady += self.onPlayerReady
|
|
|
|
|
|
|
|
GObject.timeout_add(10, self.tick)
|
|
|
|
|
2021-05-15 14:26:35 +02:00
|
|
|
GObject.timeout_add(90000, self.getPosition)
|
|
|
|
|
2018-09-26 21:14:21 +02:00
|
|
|
def tick(self):
|
2021-04-26 15:07:02 +02:00
|
|
|
self.player.QuickPlay(sys.argv[1])
|
2018-09-26 21:14:21 +02:00
|
|
|
#GObject.timeout_add(3000, self.reboot)
|
|
|
|
pass
|
|
|
|
|
2021-05-15 14:26:35 +02:00
|
|
|
def getPosition(self):
|
|
|
|
pos = self.player.Position()
|
|
|
|
print("Position:")
|
|
|
|
print(pos)
|
|
|
|
|
2018-09-26 21:14:21 +02:00
|
|
|
def onStarting(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def onStopped(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def onPlayerPlaying(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def onPlayerStopped(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def onPlayerPaused(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def onPlayerFinished(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def onPlayerFinishing(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def onPlayerLoading(self, uri):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def onPlayerReady(self,url,tags):
|
|
|
|
print('Trigger Ready')
|
|
|
|
pass
|
|
|
|
|
|
|
|
def Start(self):
|
|
|
|
print("Starting Mainloop")
|
|
|
|
# initia
|
|
|
|
self.onStarting()
|
|
|
|
try:
|
|
|
|
self.mainloop.run()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
self.Stop()
|
|
|
|
|
|
|
|
def Stop(self):
|
|
|
|
print("Stopping controller")
|
|
|
|
self.player.Stop()
|
|
|
|
self.mainloop.quit()
|
|
|
|
self.onStopped()
|
|
|
|
|
|
|
|
|
|
|
|
# Sigterm Callback function
|
|
|
|
def signalSIGTERM(self,signum):
|
|
|
|
controller.Stop()
|
|
|
|
|
|
|
|
signal.signal(signal.SIGTERM, signalSIGTERM)
|
|
|
|
|
|
|
|
controller = TestController()
|
2021-04-26 15:07:02 +02:00
|
|
|
controller.Start()
|
2018-09-26 21:14:21 +02:00
|
|
|
|
|
|
|
|