mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-13 20:00:12 +01:00
fixed merge conflic
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.pyc
|
||||||
|
*.log
|
||||||
@@ -30,7 +30,7 @@ def setup_logging():
|
|||||||
logger = setup_logging()
|
logger = setup_logging()
|
||||||
|
|
||||||
######## sets paths and constants ########
|
######## sets paths and constants ########
|
||||||
PATH_TO_BROWSER = 'C:\TestFolderStucture' #TODO replace this with pi path name when i know what makes sense
|
PATH_TO_BROWSER = 'C:/TestFolderStucture'#get_the_current_dir_path() #TODO replace this with pi path name when i know what makes sense
|
||||||
PATH_TO_DATA_OBJECTS = get_the_current_dir_path()
|
PATH_TO_DATA_OBJECTS = get_the_current_dir_path()
|
||||||
EMPTY_BANK = dict(name='',location='',length=-1,start=-1,end=-1)
|
EMPTY_BANK = dict(name='',location='',length=-1,start=-1,end=-1)
|
||||||
|
|
||||||
@@ -304,4 +304,4 @@ def convert_int_to_string_for_display(time_in_seconds):
|
|||||||
elif time_in_seconds >= 6000:
|
elif time_in_seconds >= 6000:
|
||||||
return '99:99'
|
return '99:99'
|
||||||
else:
|
else:
|
||||||
return time.strftime("%M:%S", time.gmtime(time_in_seconds))
|
return time.strftime("%M:%S", time.gmtime(time_in_seconds))
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
[{"start": -1, "length": -1, "end": -1, "location": "", "name": "extremely_minimal_video_1.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "C:\\TestFolderStucture\\minimal_videos/minimal_video_1.mp4", "name": "minimal_video_1.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "C:\\TestFolderStucture\\minimal_videos/minimal_video_2.mp4", "name": "minimal_video_2.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}]
|
[{"start": -1, "length": -1, "end": -1, "location": "", "name": "spooky_video_2.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "C:/TestFolderStucture/random_video_1.mp4", "name": "random_video_1.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "C:/TestFolderStucture/random_video_2.mp4", "name": "random_video_2.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}, {"start": -1, "length": -1, "end": -1, "location": "", "name": ""}]
|
||||||
86
omxdriver.py
86
omxdriver.py
@@ -4,7 +4,9 @@ import sys
|
|||||||
import dbus
|
import dbus
|
||||||
import subprocess
|
import subprocess
|
||||||
from time import time,strftime
|
from time import time,strftime
|
||||||
|
import data_centre
|
||||||
|
|
||||||
|
logger = data_centre.setup_logging()
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -103,8 +105,8 @@ class OMXDriver(object):
|
|||||||
# self.mon.log(self, 'dbus user ' + self.dbus_user)
|
# self.mon.log(self, 'dbus user ' + self.dbus_user)
|
||||||
# self.mon.log(self, 'dbus name ' + self.dbus_name)
|
# self.mon.log(self, 'dbus name ' + self.dbus_name)
|
||||||
|
|
||||||
# print self.omxplayer_cmd
|
# logger.info self.omxplayer_cmd
|
||||||
print("Send command to omxplayer: "+ self.omxplayer_cmd)
|
logger.info("Send command to omxplayer: "+ self.omxplayer_cmd)
|
||||||
# self._process=subprocess.Popen(self.omxplayer_cmd,shell=True,stdout=file('/home/pi/pipresents/pp_logs/stdout.txt','a'),stderr=file('/home/pi/pipresents/pp_logs/stderr.txt','a'))
|
# self._process=subprocess.Popen(self.omxplayer_cmd,shell=True,stdout=file('/home/pi/pipresents/pp_logs/stdout.txt','a'),stderr=file('/home/pi/pipresents/pp_logs/stderr.txt','a'))
|
||||||
self._process=subprocess.Popen(self.omxplayer_cmd,shell=True,stdout=file('/dev/null','a'),stderr=file('/dev/null','a'))
|
self._process=subprocess.Popen(self.omxplayer_cmd,shell=True,stdout=file('/dev/null','a'),stderr=file('/dev/null','a'))
|
||||||
self.pid=self._process.pid
|
self.pid=self._process.pid
|
||||||
@@ -119,13 +121,13 @@ class OMXDriver(object):
|
|||||||
connect_success=self.__dbus_connect()
|
connect_success=self.__dbus_connect()
|
||||||
if connect_success is True:
|
if connect_success is True:
|
||||||
# print 'SUCCESS'
|
# print 'SUCCESS'
|
||||||
print('connected to omxplayer dbus after ' + str(self.dbus_tries) + ' centisecs')
|
logger.info('connected to omxplayer dbus after ' + str(self.dbus_tries) + ' centisecs')
|
||||||
|
|
||||||
# get duration of the track in microsecs if fails return a very large duration
|
# get duration of the track in microsecs if fails return a very large duration
|
||||||
# posibly faile because omxplayer is running but not omxplayer.bin
|
# posibly faile because omxplayer is running but not omxplayer.bin
|
||||||
duration_success,duration=self.get_duration()
|
duration_success,duration=self.get_duration()
|
||||||
if duration_success is False:
|
if duration_success is False:
|
||||||
print('get duration failed for n attempts using '+ str(duration/60000000)+ ' minutes')
|
logger.info('get duration failed for n attempts using '+ str(duration/60000000)+ ' minutes')
|
||||||
# calculate time to pause before last frame
|
# calculate time to pause before last frame
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
self.pause_at_end_time = duration - 350000
|
self.pause_at_end_time = duration - 350000
|
||||||
@@ -184,7 +186,7 @@ class OMXDriver(object):
|
|||||||
self.end_play_reason='pause_at_end'
|
self.end_play_reason='pause_at_end'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print 'pause at end failed, probably because of delay after detection, just run on'
|
logger.info( 'pause at end failed, probably because of delay after detection, just run on')
|
||||||
self.widget.after(self.delay,self._status_loop)
|
self.widget.after(self.delay,self._status_loop)
|
||||||
else:
|
else:
|
||||||
# need to do the pausing for preload after first timestamp is received 0 is default value before start
|
# need to do the pausing for preload after first timestamp is received 0 is default value before start
|
||||||
@@ -199,7 +201,7 @@ class OMXDriver(object):
|
|||||||
else:
|
else:
|
||||||
# should never fail, just warn at the moment
|
# should never fail, just warn at the moment
|
||||||
# print 'pause after load failed '+ + str(self.video_position)
|
# print 'pause after load failed '+ + str(self.video_position)
|
||||||
print( str(self.id)+ ' pause after load fail ' + str(self.video_position))
|
logger.info( str(self.id)+ ' pause after load fail ' + str(self.video_position))
|
||||||
self.widget.after(self.delay,self._status_loop)
|
self.widget.after(self.delay,self._status_loop)
|
||||||
else:
|
else:
|
||||||
self.widget.after(self.delay,self._status_loop)
|
self.widget.after(self.delay,self._status_loop)
|
||||||
@@ -218,30 +220,30 @@ class OMXDriver(object):
|
|||||||
# print self.id,' unpause for show success', self.video_position
|
# print self.id,' unpause for show success', self.video_position
|
||||||
else:
|
else:
|
||||||
# should never fail, just warn at the moment
|
# should never fail, just warn at the moment
|
||||||
print(str(self.id)+ ' unpause for show fail ' + str(self.video_position))
|
logger.info(str(self.id)+ ' unpause for show fail ' + str(self.video_position))
|
||||||
|
|
||||||
|
|
||||||
def control(self,char):
|
def control(self,char):
|
||||||
|
|
||||||
val = OMXDriver.KEY_MAP[char]
|
val = OMXDriver.KEY_MAP[char]
|
||||||
print('>control received and sent to omxplayer ' + str(self.pid))
|
#logger.info('>control received and sent to omxplayer ' + str(self.pid))
|
||||||
if self.is_running():
|
if self.is_running():
|
||||||
try:
|
try:
|
||||||
self.__iface_player.Action(dbus.Int32(val))
|
self.__iface_player.Action(dbus.Int32(val))
|
||||||
except dbus.exceptions.DBusException as ex:
|
except dbus.exceptions.DBusException as ex:
|
||||||
print('Failed to send control - dbus exception: {}'.format(ex.get_dbus_message()))
|
#logger.info('Failed to send control - dbus exception: {}'.format(ex.get_dbus_message()))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print('Failed to send control - process not running')
|
logger.info('Failed to send control - process not running')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# USE ONLY at end and after load
|
# USE ONLY at end and after load
|
||||||
# return succces of the operation, several tries if pause did not work and no error reported.
|
# return succces of the operation, several tries if pause did not work and no error reported.
|
||||||
def pause(self,reason):
|
def pause(self,reason):
|
||||||
print(self,'pause received '+reason)
|
#logger.info(self,'pause received {}'.format(reason))
|
||||||
if self.paused is False:
|
if self.paused is False:
|
||||||
print('not paused so send pause '+reason)
|
logger.info('not paused so send pause {}'.format(reason))
|
||||||
tries=1
|
tries=1
|
||||||
while True:
|
while True:
|
||||||
if self.send_pause() is False:
|
if self.send_pause() is False:
|
||||||
@@ -256,12 +258,12 @@ class OMXDriver(object):
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
# failed for no good reason
|
# failed for no good reason
|
||||||
print(self, '!!!!! repeat pause ' + str(tries))
|
logger.info(self, '!!!!! repeat pause {}'.format(str(tries)))
|
||||||
# print self.id,' !!!!! repeat pause ',self.video_position, tries
|
# print self.id,' !!!!! repeat pause ',self.video_position, tries
|
||||||
tries +=1
|
tries +=1
|
||||||
if tries >5:
|
if tries >5:
|
||||||
# print self.id, ' pause failed for n attempts'
|
# print self.id, ' pause failed for n attempts'
|
||||||
print('pause failed for n attempts')
|
logger.info('pause failed for n attempts')
|
||||||
return False
|
return False
|
||||||
# repeat
|
# repeat
|
||||||
|
|
||||||
@@ -269,9 +271,9 @@ class OMXDriver(object):
|
|||||||
# USE ONLY for show
|
# USE ONLY for show
|
||||||
|
|
||||||
def unpause(self,reason):
|
def unpause(self,reason):
|
||||||
print('MON' + 'Unpause received '+ reason)
|
logger.info('MON' + 'Unpause received {}'.format(reason))
|
||||||
if self.paused is True:
|
if self.paused is True:
|
||||||
print('MON' +'Is paused so Track will be unpaused '+ reason)
|
logger.info('MON' +'Is paused so Track will be unpaused {}'.format(reason))
|
||||||
tries=1
|
tries=1
|
||||||
while True:
|
while True:
|
||||||
if self.send_unpause() is False:
|
if self.send_unpause() is False:
|
||||||
@@ -287,12 +289,12 @@ class OMXDriver(object):
|
|||||||
# failed for good reason because of exception or process not running caused by end of track
|
# failed for good reason because of exception or process not running caused by end of track
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print('warn' + '!!!!! repeat unpause ' + str(tries))
|
logger.info('warn' + '!!!!! repeat unpause {}'.format(tries))
|
||||||
# print self.id,' !!!! repeat unpause ',self.video_position, tries
|
# print self.id,' !!!! repeat unpause ',self.video_position, tries
|
||||||
tries +=1
|
tries +=1
|
||||||
if tries >5:
|
if tries >5:
|
||||||
# print self.id, ' unpause failed for n attempts'
|
# print self.id, ' unpause failed for n attempts'
|
||||||
print('warn' + 'unpause failed for n attempts')
|
logger.info('warn' + 'unpause failed for n attempts')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@@ -301,11 +303,11 @@ class OMXDriver(object):
|
|||||||
try:
|
try:
|
||||||
result=self.__iface_props.PlaybackStatus()
|
result=self.__iface_props.PlaybackStatus()
|
||||||
except dbus.exceptions.DBusException as ex:
|
except dbus.exceptions.DBusException as ex:
|
||||||
print('warn'+'Failed to test paused - dbus exception: {}'.format(ex.get_dbus_message()))
|
logger.info('warn'+'Failed to test paused - dbus exception: {}'.format(ex.get_dbus_message()))
|
||||||
return 'Failed'
|
return 'Failed'
|
||||||
return result
|
return result
|
||||||
else:
|
else:
|
||||||
print('warn'+'Failed to test paused - process not running')
|
logger.info('warn'+'Failed to test paused - process not running')
|
||||||
# print self.id,' test paused not successful - process'
|
# print self.id,' test paused not successful - process'
|
||||||
return 'Failed'
|
return 'Failed'
|
||||||
|
|
||||||
@@ -315,11 +317,11 @@ class OMXDriver(object):
|
|||||||
try:
|
try:
|
||||||
self.__iface_player.Pause()
|
self.__iface_player.Pause()
|
||||||
except dbus.exceptions.DBusException as ex:
|
except dbus.exceptions.DBusException as ex:
|
||||||
print('warn'+'Failed to send pause - dbus exception: {}'.format(ex.get_dbus_message()))
|
logger.info('warn'+'Failed to send pause - dbus exception: {}'.format(ex.get_dbus_message()))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print('warn'+'Failed to send pause - process not running')
|
logger.info('warn'+'Failed to send pause - process not running')
|
||||||
# print self.id,' send pause not successful - process'
|
# print self.id,' send pause not successful - process'
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -329,16 +331,16 @@ class OMXDriver(object):
|
|||||||
try:
|
try:
|
||||||
self.__iface_player.Action(16)
|
self.__iface_player.Action(16)
|
||||||
except dbus.exceptions.DBusException as ex:
|
except dbus.exceptions.DBusException as ex:
|
||||||
print('warn'+'Failed to send unpause - dbus exception: {}'.format(ex.get_dbus_message()))
|
logger.info('warn'+'Failed to send unpause - dbus exception: {}'.format(ex.get_dbus_message()))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print('warn'+'Failed to send unpause - process not running')
|
logger.info('warn'+'Failed to send unpause - process not running')
|
||||||
# print self.id,' send unpause not successful - process'
|
# print self.id,' send unpause not successful - process'
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def pause_on(self):
|
def pause_on(self):
|
||||||
print('mon'+'pause on received ')
|
logger.info('mon'+'pause on received ')
|
||||||
# print 'pause on',self.paused
|
# print 'pause on',self.paused
|
||||||
if self.paused is True:
|
if self.paused is True:
|
||||||
return
|
return
|
||||||
@@ -350,15 +352,15 @@ class OMXDriver(object):
|
|||||||
# print 'paused OK'
|
# print 'paused OK'
|
||||||
return
|
return
|
||||||
except dbus.exceptions.DBusException as ex:
|
except dbus.exceptions.DBusException as ex:
|
||||||
print('warn'+'Failed to do pause on - dbus exception: {}'.format(ex.get_dbus_message()))
|
logger.info('warn'+'Failed to do pause on - dbus exception: {}'.format(ex.get_dbus_message()))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print('warn'+'Failed to do pause on - process not running')
|
logger.info('warn'+'Failed to do pause on - process not running')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def pause_off(self):
|
def pause_off(self):
|
||||||
print('mon'+'pause off received ')
|
logger.info('mon'+'pause off received ')
|
||||||
# print 'pause off',self.paused
|
# print 'pause off',self.paused
|
||||||
if self.paused is False:
|
if self.paused is False:
|
||||||
return
|
return
|
||||||
@@ -369,14 +371,14 @@ class OMXDriver(object):
|
|||||||
# print 'not paused OK'
|
# print 'not paused OK'
|
||||||
return
|
return
|
||||||
except dbus.exceptions.DBusException as ex:
|
except dbus.exceptions.DBusException as ex:
|
||||||
print('warn'+'Failed to do pause off - dbus exception: {}'.format(ex.get_dbus_message()))
|
logger.info('warn'+'Failed to do pause off - dbus exception: {}'.format(ex.get_dbus_message()))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print('warn'+'Failed to do pause off - process not running')
|
logger.info('warn'+'Failed to do pause off - process not running')
|
||||||
return
|
return
|
||||||
|
|
||||||
def go(self):
|
def go(self):
|
||||||
print('log'+'go received ')
|
logger.info('log'+'go received ')
|
||||||
self.unpause('for go')
|
self.unpause('for go')
|
||||||
|
|
||||||
|
|
||||||
@@ -392,7 +394,7 @@ class OMXDriver(object):
|
|||||||
|
|
||||||
|
|
||||||
def toggle_pause(self,reason):
|
def toggle_pause(self,reason):
|
||||||
print('log'+'toggle pause received '+ reason)
|
logger.info('log'+'toggle pause received {}'.format(reason))
|
||||||
if not self.paused:
|
if not self.paused:
|
||||||
self.paused = True
|
self.paused = True
|
||||||
else:
|
else:
|
||||||
@@ -401,16 +403,16 @@ class OMXDriver(object):
|
|||||||
try:
|
try:
|
||||||
self.__iface_player.Action(16)
|
self.__iface_player.Action(16)
|
||||||
except dbus.exceptions.DBusException as ex:
|
except dbus.exceptions.DBusException as ex:
|
||||||
print('warn'+'Failed to toggle pause - dbus exception: {}'.format(ex.get_dbus_message()))
|
logger.info('warn'+'Failed to toggle pause - dbus exception: {}'.format(ex.get_dbus_message()))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print('warn'+'Failed to toggle pause - process not running')
|
logger.info('warn'+'Failed to toggle pause - process not running')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
print('log'+'>stop received and quit sent to omxplayer ' + str(self.pid))
|
logger.info('log'+'>stop received and quit sent to omxplayer {} '.format(self.pid))
|
||||||
# need to send 'nice day'
|
# need to send 'nice day'
|
||||||
if self.paused_at_end is True:
|
if self.paused_at_end is True:
|
||||||
self.end_play_signal=True
|
self.end_play_signal=True
|
||||||
@@ -420,10 +422,10 @@ class OMXDriver(object):
|
|||||||
try:
|
try:
|
||||||
self.__iface_root.Quit()
|
self.__iface_root.Quit()
|
||||||
except dbus.exceptions.DBusException as ex:
|
except dbus.exceptions.DBusException as ex:
|
||||||
print('warn'+'Failed to quit - dbus exception: {}'.format(ex.get_dbus_message()))
|
logger.info('warn'+'Failed to quit - dbus exception: {}'.format(ex.get_dbus_message()))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print('warn'+'Failed to quit - process not running')
|
logger.info('warn'+'Failed to quit - process not running')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@@ -471,7 +473,7 @@ class OMXDriver(object):
|
|||||||
if success is True:
|
if success is True:
|
||||||
return True,duration
|
return True,duration
|
||||||
else:
|
else:
|
||||||
print('warn'+ 'repeat get duration ' + str(tries))
|
logger.info('warn'+ 'repeat get duration {}'.format(tries))
|
||||||
tries +=1
|
tries +=1
|
||||||
if tries >5:
|
if tries >5:
|
||||||
return False,sys.maxint*100
|
return False,sys.maxint*100
|
||||||
@@ -484,7 +486,7 @@ class OMXDriver(object):
|
|||||||
micros = self.__iface_props.Duration()
|
micros = self.__iface_props.Duration()
|
||||||
return True,micros
|
return True,micros
|
||||||
except dbus.exceptions.DBusException as ex:
|
except dbus.exceptions.DBusException as ex:
|
||||||
print('warn'+'Failed get duration - dbus exception: {}'.format(ex.get_dbus_message()))
|
logger.info('warn'+'Failed get duration - dbus exception: {}'.format(ex.get_dbus_message()))
|
||||||
return False,-1
|
return False,-1
|
||||||
else:
|
else:
|
||||||
return False,-1
|
return False,-1
|
||||||
@@ -502,20 +504,20 @@ class OMXDriver(object):
|
|||||||
bus_pid_filename = "/tmp/omxplayerdbus.{}.pid".format(self.dbus_user)
|
bus_pid_filename = "/tmp/omxplayerdbus.{}.pid".format(self.dbus_user)
|
||||||
|
|
||||||
if not os.path.exists(bus_address_filename):
|
if not os.path.exists(bus_address_filename):
|
||||||
print('log'+'waiting for bus address file ' + bus_address_filename)
|
logger.info('log'+'waiting for bus address file {}'.format(bus_address_filename))
|
||||||
self.omx_loaded=False
|
self.omx_loaded=False
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
f = open(bus_address_filename, "r")
|
f = open(bus_address_filename, "r")
|
||||||
bus_address = f.read().rstrip()
|
bus_address = f.read().rstrip()
|
||||||
if bus_address == '':
|
if bus_address == '':
|
||||||
print('log'+ 'waiting for bus address in file ' + bus_address_filename)
|
logger.info('log'+ 'waiting for bus address in file {}'.format(bus_address_filename))
|
||||||
self.omx_loaded=False
|
self.omx_loaded=False
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
# self.mon.log(self, 'bus address found ' + bus_address)
|
# self.mon.log(self, 'bus address found ' + bus_address)
|
||||||
if not os.path.exists(bus_pid_filename):
|
if not os.path.exists(bus_pid_filename):
|
||||||
print('warn'+ 'bus pid file does not exist ' + bus_pid_filename)
|
logger.info('warn'+ 'bus pid file does not exist {}'.format(bus_pid_filename))
|
||||||
self.omx_loaded=False
|
self.omx_loaded=False
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
|||||||
BIN
omxdriver.pyc
Normal file
BIN
omxdriver.pyc
Normal file
Binary file not shown.
@@ -1 +1 @@
|
|||||||
[{"name": "PLAYBACK_MODE", "value": "RANDOM"}, {"name": "PLAYLIST", "value": "[1,1,1,4,1,2,1,4]"}, {"name": "SYNC_LENGTHS", "value": "OFF"}, {"name": "SYNC_LENGTHS_TO", "value": "00:08"}, {"name": "RAND_START", "value": "OFF"}, {"name": "VIDEO_OUTPUT", "value": "HDMI"}]
|
[{"name": "PLAYBACK_MODE", "value": "LOOPER"}, {"name": "PLAYLIST", "value": "[1,1,1,4,1,2,1,4]"}, {"name": "SYNC_LENGTHS", "value": "OFF"}, {"name": "SYNC_LENGTHS_TO", "value": "00:08"}, {"name": "RAND_START", "value": "OFF"}, {"name": "VIDEO_OUTPUT", "value": "HDMI"}]
|
||||||
@@ -1,26 +1,36 @@
|
|||||||
import time
|
import time
|
||||||
#from omxdriver import OMXDriver <== for deving only
|
try:
|
||||||
|
from omxdriver import OMXDriver #<== for deving only
|
||||||
|
has_omx = True
|
||||||
|
except ImportError:
|
||||||
|
has_omx = False
|
||||||
from Tkinter import Tk, Canvas
|
from Tkinter import Tk, Canvas
|
||||||
import data_centre
|
import data_centre
|
||||||
|
|
||||||
|
logger = data_centre.setup_logging()
|
||||||
|
#layer = 0
|
||||||
|
|
||||||
|
|
||||||
class video_driver(object):
|
class video_driver(object):
|
||||||
def __init__(self, widget = None):
|
def __init__(self, widget = None):
|
||||||
|
|
||||||
self.widget = widget
|
self.widget = widget
|
||||||
self.delay = 50
|
self.delay = 50
|
||||||
self.last_player = video_player(self.widget,'a')
|
logger.info('the has_omx flag is {}'.format(has_omx))
|
||||||
self.current_player = video_player(self.widget,'b')
|
if has_omx:
|
||||||
self.next_player = video_player(self.widget,'c')
|
self.last_player = video_player(self.widget,'a')
|
||||||
|
self.current_player = video_player(self.widget,'b')
|
||||||
|
self.next_player = video_player(self.widget,'c')
|
||||||
|
self.manual_next = False
|
||||||
|
|
||||||
self.manual_next = False
|
self.widget.after(self.delay,self.begin_playing)
|
||||||
|
|
||||||
self.begin_playing()
|
|
||||||
|
|
||||||
def begin_playing(self):
|
def begin_playing(self):
|
||||||
#TODO: the first clip will be a demo
|
#TODO: the first clip will be a demo
|
||||||
first_context = data_centre.get_next_context()
|
first_context = data_centre.get_next_context()
|
||||||
#first_context = '/home/pi/pp_home/media/samplerloop3s.mp4'
|
#first_context = '/home/pi/pp_home/media/01_trashpalaceintro.mp4'
|
||||||
self.current_player.load_content(first_context)
|
logger.info(first_context['location'])
|
||||||
|
self.current_player.load_content(first_context['location'])
|
||||||
|
|
||||||
self.wait_for_first_load()
|
self.wait_for_first_load()
|
||||||
|
|
||||||
@@ -34,21 +44,21 @@ class video_driver(object):
|
|||||||
def switch_players(self):
|
def switch_players(self):
|
||||||
self.temp_player = self.last_player
|
self.temp_player = self.last_player
|
||||||
self.last_player = self.current_player
|
self.last_player = self.current_player
|
||||||
print('switch: last_player is {}'.format(self.last_player.name))
|
logger.info('switch: last_player is {}'.format(self.last_player.name))
|
||||||
self.current_player = self.next_player
|
self.current_player = self.next_player
|
||||||
print('switch: current_player is {}'.format(self.current_player.name))
|
logger.info('switch: current_player is {}'.format(self.current_player.name))
|
||||||
self.next_player = self.temp_player
|
self.next_player = self.temp_player
|
||||||
print('switch: next_player is {}'.format(self.next_player.name))
|
logger.info('switch: next_player is {}'.format(self.next_player.name))
|
||||||
self.last_player.exit()
|
self.last_player.exit()
|
||||||
|
|
||||||
def play_video(self):
|
def play_video(self):
|
||||||
print('{} is about to play'.format(self.current_player.name))
|
logger.info('{} is about to play'.format(self.current_player.name))
|
||||||
self.current_player.play_content()
|
self.current_player.play_content()
|
||||||
#self.last_player.exit()
|
#self.last_player.exit()
|
||||||
|
|
||||||
next_context = data_centre.get_next_context()
|
next_context = data_centre.get_next_context()
|
||||||
#next_context = '/home/pi/pp_home/media/samplerloop3s.mp4'
|
#next_context = '/home/pi/pp_home/media/samplerloop3s.mp4'
|
||||||
self.next_player.load_content(next_context)
|
self.next_player.load_content(next_context['location'])
|
||||||
|
|
||||||
self.wait_for_next_cycle()
|
self.wait_for_next_cycle()
|
||||||
|
|
||||||
@@ -56,14 +66,14 @@ class video_driver(object):
|
|||||||
def wait_for_next_cycle(self):
|
def wait_for_next_cycle(self):
|
||||||
|
|
||||||
if(self.current_player.is_finished() or self.manual_next):
|
if(self.current_player.is_finished() or self.manual_next):
|
||||||
print('{} is finished'.format(self.current_player.name))
|
logger.info('{} is finished'.format(self.current_player.name))
|
||||||
self.manual_next = False
|
self.manual_next = False
|
||||||
if self.next_player.is_loaded():
|
if self.next_player.is_loaded():
|
||||||
print('{} is loaded on switchover'.format(self.next_player.name))
|
logger.info('{} is loaded on switchover'.format(self.next_player.name))
|
||||||
self.switch_players()
|
self.switch_players()
|
||||||
self.play_video()
|
self.play_video()
|
||||||
else:
|
else:
|
||||||
print('{} is not loaded yet!'.format(self.next_player.name))
|
logger.info('{} is not loaded yet!'.format(self.next_player.name))
|
||||||
self.current_player.pause_content()
|
self.current_player.pause_content()
|
||||||
self.wait_for_next_load()
|
self.wait_for_next_load()
|
||||||
else:
|
else:
|
||||||
@@ -78,8 +88,11 @@ class video_driver(object):
|
|||||||
|
|
||||||
|
|
||||||
def get_info_for_video_display(self):
|
def get_info_for_video_display(self):
|
||||||
return self.current_player.bank_number, self.current_player.status, self.next_player.bank_number,\
|
if has_omx:
|
||||||
|
return self.current_player.bank_number, self.current_player.status, self.next_player.bank_number,\
|
||||||
self.next_player.status, self.current_player.duration, self.current_player.video_length
|
self.next_player.status, self.current_player.duration, self.current_player.video_length
|
||||||
|
else:
|
||||||
|
return 0, 'test', 1, 'test' , 0, 10
|
||||||
|
|
||||||
|
|
||||||
class video_player(object):
|
class video_player(object):
|
||||||
@@ -105,14 +118,18 @@ class video_player(object):
|
|||||||
|
|
||||||
def play_content(self):
|
def play_content(self):
|
||||||
self.status = 'PLAYING'
|
self.status = 'PLAYING'
|
||||||
print('{} is playing now'.format(self.name))
|
logger.info('{} is playing now'.format(self.name))
|
||||||
self.omx.pause_before_play_required = 'no'
|
self.omx.pause_before_play_required = 'no'
|
||||||
self.omx.show(True,0)
|
self.omx.show(True,0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def load_content(self, context):
|
def load_content(self, context):
|
||||||
self.status = 'LOADING'
|
self.status = 'LOADING'
|
||||||
print('{} is loading now {}'.format(self.name,context))
|
logger.info('{} is loading now {}'.format(self.name,context))
|
||||||
self.omx.load(context,'after-first-frame','','')
|
self.omx.load(context,'after-first-frame','--win 0,0,400,400 --no-osd','')
|
||||||
|
|
||||||
|
#layer = layer + 1
|
||||||
|
|
||||||
def set_to_default(self):
|
def set_to_default(self):
|
||||||
self.omx.kill()
|
self.omx.kill()
|
||||||
@@ -120,19 +137,19 @@ class video_player(object):
|
|||||||
|
|
||||||
def exit(self):
|
def exit(self):
|
||||||
if(self.omx.omx_loaded is not None):
|
if(self.omx.omx_loaded is not None):
|
||||||
print('{} is exiting omx'.format(self.name))
|
logger.info('{} is exiting omx'.format(self.name))
|
||||||
self.omx.stop()
|
self.omx.stop()
|
||||||
self.omx = OMXDriver(self.widget,'')
|
self.omx = OMXDriver(self.widget,'')
|
||||||
|
|
||||||
def pause_content(self):
|
def pause_content(self):
|
||||||
self.status = 'PAUSED'
|
self.status = 'PAUSED'
|
||||||
|
|
||||||
# tk = Tk()
|
#tk = Tk()
|
||||||
#
|
|
||||||
# canvas = Canvas(tk,width=500,height=400, bd=0, highlightthickness=0)
|
#canvas = Canvas(tk,width=500,height=400, bd=0, highlightthickness=0)
|
||||||
# canvas.pack()
|
#canvas.pack()
|
||||||
#
|
|
||||||
# driver = video_driver(canvas)
|
#driver = video_driver(canvas)
|
||||||
#
|
|
||||||
# while True:
|
#while True:
|
||||||
# tk.update()
|
# tk.update()
|
||||||
|
|||||||
Reference in New Issue
Block a user