91 lines
1.9 KiB
Python
Executable File
91 lines
1.9 KiB
Python
Executable File
#!/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)
|
|
|
|
def tick(self):
|
|
self.player.QuickLoop("/opt/src/robotvideo/ogen open.mp4")
|
|
#GObject.timeout_add(3000, self.reboot)
|
|
pass
|
|
|
|
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()
|
|
controller.Start();
|
|
|
|
|