From 9d56b2fb35f115e364f8504e11b4b88504445443 Mon Sep 17 00:00:00 2001 From: langolierz Date: Fri, 6 Oct 2017 07:12:36 +0000 Subject: [PATCH 1/3] first commit from pi --- data_centre.py | 4 +-- display_centre.py | 15 ++++---- display_data.json | 2 +- omxdriver.py | 86 ++++++++++++++++++++++++---------------------- omxdriver.pyc | Bin 0 -> 13944 bytes settings.json | 2 +- video_centre.py | 63 ++++++++++++++++++--------------- 7 files changed, 92 insertions(+), 80 deletions(-) create mode 100644 omxdriver.pyc diff --git a/data_centre.py b/data_centre.py index e4faaad..5f80c37 100644 --- a/data_centre.py +++ b/data_centre.py @@ -30,7 +30,7 @@ def setup_logging(): logger = setup_logging() ######## 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 = '/home/pi/pp_home/media' #TODO replace this with pi path name when i know what makes sense PATH_TO_DATA_OBJECTS = get_the_current_dir_path() 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: return '99:99' else: - return time.strftime("%M:%S", time.gmtime(time_in_seconds)) \ No newline at end of file + return time.strftime("%M:%S", time.gmtime(time_in_seconds)) diff --git a/display_centre.py b/display_centre.py index 1505dfc..fa26785 100644 --- a/display_centre.py +++ b/display_centre.py @@ -33,7 +33,7 @@ class Display(Frame): ) self._last_frame = 0 self.video_driver = driver - self.my_frame_update_count = 40 + self.my_frame_update_count = 5 layout_top = Layout([1,1,1]) self.add_layout(layout_top) @@ -79,7 +79,6 @@ class Display(Frame): banner = create_video_display_banner(duration,video_length) time_been = data_centre.convert_int_to_string_for_display(duration) time_left = data_centre.convert_int_to_string_for_display(video_length - duration) - logger.info(VIDEO_DISPLAY_BANNER_TEXT.format(time_been,banner,time_left)) return VIDEO_DISPLAY_BANNER_TEXT.format(time_been,banner,time_left),VIDEO_DISPLAY_TEXT.format(now_bank , now_status, next_bank, next_status, duration) def _update(self, frame_no): @@ -129,6 +128,7 @@ class Browser(Display): numberMapping = [ord('q'),ord('w'),ord('e'),ord('r'),ord('t'),ord('y'),ord('u'),ord('i'),ord('o'),ord('p') ] if isinstance(event, KeyboardEvent): + logger.info('the button you just pressed was {}'.format(event.key_code)) if event.key_code in numberMapping: focus = self.get_focus_on_list(self._browser_data_view) @@ -161,7 +161,6 @@ class Browser(Display): # Now pass on to lower levels for normal handling of the event. def _update(self, frame_no): - logger.info('the BROWSER frame number is {}'.format(frame_no)) super(Browser, self)._update(frame_no) def _reload_list(self, new_value=None): @@ -256,14 +255,16 @@ def demo(screen, tk): Scene([Settings(screen, data,video_driver)], -1)] screen.play(scenes,tk) -data = data_centre.data() -video_driver = video_centre.video_driver() -last_scene = None - tk = Tk() canvas = Canvas(tk, width=500, height=400, bd=0, highlightthickness=0) canvas.pack() +data = data_centre.data() + +video_driver = video_centre.video_driver(canvas) + +last_scene = None + while True: try: Screen.wrapper(demo, catch_interrupt=True, arguments=(tk,)) diff --git a/display_data.json b/display_data.json index a697d32..c7da799 100644 --- a/display_data.json +++ b/display_data.json @@ -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": ""}] \ No newline at end of file +[{"start": -1, "length": -1, "end": -1, "location": "/home/pi/pp_home/media/samplerloop3s3.mp4", "name": "samplerloop3s3.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "/home/pi/pp_home/media/5sec.mp4", "name": "5sec.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "/home/pi/pp_home/media/xthresh.mp4", "name": "xthresh.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "/home/pi/pp_home/media/samplerloop3s2.mp4", "name": "samplerloop3s2.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": "/home/pi/pp_home/media/samplerloop3s2.mp4", "name": "samplerloop3s2.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": ""}] \ No newline at end of file diff --git a/omxdriver.py b/omxdriver.py index 366aa99..e78d8e7 100644 --- a/omxdriver.py +++ b/omxdriver.py @@ -4,7 +4,9 @@ import sys import dbus import subprocess 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 name ' + self.dbus_name) - # print self.omxplayer_cmd - print("Send command to omxplayer: "+ self.omxplayer_cmd) + # logger.info 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('/dev/null','a'),stderr=file('/dev/null','a')) self.pid=self._process.pid @@ -119,13 +121,13 @@ class OMXDriver(object): connect_success=self.__dbus_connect() if connect_success is True: # 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 # posibly faile because omxplayer is running but not omxplayer.bin duration_success,duration=self.get_duration() 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 self.duration = duration self.pause_at_end_time = duration - 350000 @@ -184,7 +186,7 @@ class OMXDriver(object): self.end_play_reason='pause_at_end' return 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) else: # 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: # should never fail, just warn at the moment # 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) else: 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 else: # 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): 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(): try: self.__iface_player.Action(dbus.Int32(val)) 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 else: - print('Failed to send control - process not running') + logger.info('Failed to send control - process not running') return # USE ONLY at end and after load # return succces of the operation, several tries if pause did not work and no error reported. def pause(self,reason): - print(self,'pause received '+reason) + #logger.info(self,'pause received {}'.format(reason)) if self.paused is False: - print('not paused so send pause '+reason) + logger.info('not paused so send pause {}'.format(reason)) tries=1 while True: if self.send_pause() is False: @@ -256,12 +258,12 @@ class OMXDriver(object): return False else: # 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 tries +=1 if tries >5: # print self.id, ' pause failed for n attempts' - print('pause failed for n attempts') + logger.info('pause failed for n attempts') return False # repeat @@ -269,9 +271,9 @@ class OMXDriver(object): # USE ONLY for show def unpause(self,reason): - print('MON' + 'Unpause received '+ reason) + logger.info('MON' + 'Unpause received {}'.format(reason)) 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 while True: 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 return False else: - print('warn' + '!!!!! repeat unpause ' + str(tries)) + logger.info('warn' + '!!!!! repeat unpause {}'.format(tries)) # print self.id,' !!!! repeat unpause ',self.video_position, tries tries +=1 if tries >5: # 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 @@ -301,11 +303,11 @@ class OMXDriver(object): try: result=self.__iface_props.PlaybackStatus() 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 result 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' return 'Failed' @@ -315,11 +317,11 @@ class OMXDriver(object): try: self.__iface_player.Pause() 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 True 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' return False @@ -329,16 +331,16 @@ class OMXDriver(object): try: self.__iface_player.Action(16) 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 True 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' return False def pause_on(self): - print('mon'+'pause on received ') + logger.info('mon'+'pause on received ') # print 'pause on',self.paused if self.paused is True: return @@ -350,15 +352,15 @@ class OMXDriver(object): # print 'paused OK' return 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 else: - print('warn'+'Failed to do pause on - process not running') + logger.info('warn'+'Failed to do pause on - process not running') return def pause_off(self): - print('mon'+'pause off received ') + logger.info('mon'+'pause off received ') # print 'pause off',self.paused if self.paused is False: return @@ -369,14 +371,14 @@ class OMXDriver(object): # print 'not paused OK' return 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 else: - print('warn'+'Failed to do pause off - process not running') + logger.info('warn'+'Failed to do pause off - process not running') return def go(self): - print('log'+'go received ') + logger.info('log'+'go received ') self.unpause('for go') @@ -392,7 +394,7 @@ class OMXDriver(object): def toggle_pause(self,reason): - print('log'+'toggle pause received '+ reason) + logger.info('log'+'toggle pause received {}'.format(reason)) if not self.paused: self.paused = True else: @@ -401,16 +403,16 @@ class OMXDriver(object): try: self.__iface_player.Action(16) 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 else: - print('warn'+'Failed to toggle pause - process not running') + logger.info('warn'+'Failed to toggle pause - process not running') return 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' if self.paused_at_end is True: self.end_play_signal=True @@ -420,10 +422,10 @@ class OMXDriver(object): try: self.__iface_root.Quit() 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 else: - print('warn'+'Failed to quit - process not running') + logger.info('warn'+'Failed to quit - process not running') return @@ -471,7 +473,7 @@ class OMXDriver(object): if success is True: return True,duration else: - print('warn'+ 'repeat get duration ' + str(tries)) + logger.info('warn'+ 'repeat get duration {}'.format(tries)) tries +=1 if tries >5: return False,sys.maxint*100 @@ -484,7 +486,7 @@ class OMXDriver(object): micros = self.__iface_props.Duration() return True,micros 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 else: return False,-1 @@ -502,20 +504,20 @@ class OMXDriver(object): bus_pid_filename = "/tmp/omxplayerdbus.{}.pid".format(self.dbus_user) 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 return False else: f = open(bus_address_filename, "r") bus_address = f.read().rstrip() 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 return False else: # self.mon.log(self, 'bus address found ' + bus_address) 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 return False else: diff --git a/omxdriver.pyc b/omxdriver.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8e5e1d740d2167bd651eb26dfb69422fb9729dcc GIT binary patch literal 13944 zcmcgz+m9SqT0hm@bLsJn?HSK_V#k-tg`H-TnF)zVmTWeOlW`Jn;*P0_Y_jJ{a zYuwY_Q&nwyHnFlRFN#=TB?J$EL=Zw+BqStO2+;Dh;sGJS0}_HiVBdJ*VHY9sLiqiD zr>ZaGw&R(VuwAFWI(07JIp6&|$HkvbO+4@a=t|vWe~S2h9Z&LI6aoG@reVz0F6@}A zPF`OyR|`2@G*^o`TryWnf(xcGVzx%iRg|OV>ZozD5y#BcF%yoN&2e)NqnAxkG~t9< z$IvB%nNfM=>H$u^S{VT%(dYP6trP&JB^J?En2rNT(s*4jWxTw9{_;v3-3sG@)x5!G z&p5_}m`S)3YpkPaBA^VoXkNs$!HE4CH7^qVG2#KlgK+_)CMXLSGr@#_aT6R60PH6P zOqgIw05Cr&VA2GK1WcLWuz-Umm=gzLo)q93 zZ?*CiHZA(gS3dtdISFXFlf=twQFFPqb*J5^?S!$rxY%qh-VApVH=0I^6#HuyqnR9h zMipPH7g527lzS6T@<%8>cFf1d_y7t59Ftn0m;=~<+Xnk@KVknZFqXF&&jIYe{e=B5 zYQO{eC+vSoHQ0Ylhe@&R7QnV!0NZW>Y`e+$t(uMj&t@yV5j8g=fF>myzEx`^VanIa z5!Q{OxE%!>V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&9$K(MO$-r%`*xLOK|*oeUbrUsW@22nknRoCeen0!Q)7T&N;_;xxuMCfsvFy^>r28 z_l32Oo1#Id5&FLObu{o8h|mCJXYa_e(7B7!Sm<7tVuPTJw2r7*0O}MEqZtP8+wuHa4JmBoY#lj8o{N b?qhYL<13bOuX1WxP@eVLzegDve)<0Z3t`MS literal 0 HcmV?d00001 diff --git a/settings.json b/settings.json index 427cf5e..8c7c8b8 100644 --- a/settings.json +++ b/settings.json @@ -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"}] \ No newline at end of file +[{"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"}] \ No newline at end of file diff --git a/video_centre.py b/video_centre.py index a8b6df2..3950f46 100644 --- a/video_centre.py +++ b/video_centre.py @@ -1,11 +1,15 @@ import time -#from omxdriver import OMXDriver <== for deving only +from omxdriver import OMXDriver #<== for deving only from Tkinter import Tk, Canvas import data_centre +logger = data_centre.setup_logging() +#layer = 0 + + class video_driver(object): def __init__(self, widget = None): - + logger.info('this is a test') self.widget = widget self.delay = 50 self.last_player = video_player(self.widget,'a') @@ -14,13 +18,14 @@ class video_driver(object): self.manual_next = False - self.begin_playing() + self.widget.after(self.delay,self.begin_playing) def begin_playing(self): #TODO: the first clip will be a demo first_context = data_centre.get_next_context() - #first_context = '/home/pi/pp_home/media/samplerloop3s.mp4' - self.current_player.load_content(first_context) + #first_context = '/home/pi/pp_home/media/01_trashpalaceintro.mp4' + logger.info(first_context['location']) + self.current_player.load_content(first_context['location']) self.wait_for_first_load() @@ -34,21 +39,21 @@ class video_driver(object): def switch_players(self): self.temp_player = self.last_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 - 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 - 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() 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.last_player.exit() next_context = data_centre.get_next_context() #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() @@ -56,14 +61,14 @@ class video_driver(object): def wait_for_next_cycle(self): 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 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.play_video() 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.wait_for_next_load() else: @@ -105,14 +110,18 @@ class video_player(object): def play_content(self): 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.show(True,0) + self.omx.show(True,0) + + def load_content(self, context): self.status = 'LOADING' - print('{} is loading now {}'.format(self.name,context)) - self.omx.load(context,'after-first-frame','','') + logger.info('{} is loading now {}'.format(self.name,context)) + self.omx.load(context,'after-first-frame','--win 0,0,400,400 --no-osd','') + + #layer = layer + 1 def set_to_default(self): self.omx.kill() @@ -120,19 +129,19 @@ class video_player(object): def exit(self): 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 = OMXDriver(self.widget,'') def pause_content(self): self.status = 'PAUSED' -# tk = Tk() -# -# canvas = Canvas(tk,width=500,height=400, bd=0, highlightthickness=0) -# canvas.pack() -# -# driver = video_driver(canvas) -# -# while True: -# tk.update() +#tk = Tk() + +#canvas = Canvas(tk,width=500,height=400, bd=0, highlightthickness=0) +#canvas.pack() + +#driver = video_driver(canvas) + +#while True: +# tk.update() From 4ed1263e9ed6fb4ba4a61c19313fce16fa0f1518 Mon Sep 17 00:00:00 2001 From: Tim Caldwell Date: Fri, 6 Oct 2017 21:32:39 +1300 Subject: [PATCH 2/3] trying to make it run on both a computer of local deving and the pi --- .gitignore | 2 ++ data_centre.py | 2 +- display_centre.py | 6 +++++- video_centre.py | 36 ++++++++++++++++++++++-------------- 4 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..939db29 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc +*.log \ No newline at end of file diff --git a/data_centre.py b/data_centre.py index 5f80c37..ceb5b44 100644 --- a/data_centre.py +++ b/data_centre.py @@ -30,7 +30,7 @@ def setup_logging(): logger = setup_logging() ######## sets paths and constants ######## -PATH_TO_BROWSER = '/home/pi/pp_home/media' #TODO replace this with pi path name when i know what makes sense +PATH_TO_BROWSER = 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() EMPTY_BANK = dict(name='',location='',length=-1,start=-1,end=-1) diff --git a/display_centre.py b/display_centre.py index fa26785..e37ae15 100644 --- a/display_centre.py +++ b/display_centre.py @@ -261,7 +261,11 @@ canvas.pack() data = data_centre.data() -video_driver = video_centre.video_driver(canvas) +try: + video_driver = video_centre.video_driver(canvas) +except Exception as e: + logger.error(traceback.format_exc()) + logger.error(str(e)) last_scene = None diff --git a/video_centre.py b/video_centre.py index 3950f46..c8378e0 100644 --- a/video_centre.py +++ b/video_centre.py @@ -1,5 +1,9 @@ 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 import data_centre @@ -9,22 +13,23 @@ logger = data_centre.setup_logging() class video_driver(object): def __init__(self, widget = None): - logger.info('this is a test') + self.widget = widget self.delay = 50 - self.last_player = video_player(self.widget,'a') - self.current_player = video_player(self.widget,'b') - self.next_player = video_player(self.widget,'c') + logger.info('the has_omx flag is {}'.format(has_omx)) + if has_omx: + 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.widget.after(self.delay,self.begin_playing) def begin_playing(self): #TODO: the first clip will be a demo first_context = data_centre.get_next_context() #first_context = '/home/pi/pp_home/media/01_trashpalaceintro.mp4' - logger.info(first_context['location']) + logger.info(first_context['location']) self.current_player.load_content(first_context['location']) self.wait_for_first_load() @@ -83,8 +88,11 @@ class video_driver(object): 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 + else: + return 0, 'test', 1, 'test' , 0, 10 class video_player(object): @@ -110,18 +118,18 @@ class video_player(object): def play_content(self): self.status = 'PLAYING' - logger.info('{} is playing now'.format(self.name)) + logger.info('{} is playing now'.format(self.name)) self.omx.pause_before_play_required = 'no' - self.omx.show(True,0) + self.omx.show(True,0) def load_content(self, context): self.status = 'LOADING' logger.info('{} is loading now {}'.format(self.name,context)) - self.omx.load(context,'after-first-frame','--win 0,0,400,400 --no-osd','') + self.omx.load(context,'after-first-frame','--win 0,0,400,400 --no-osd','') - #layer = layer + 1 + #layer = layer + 1 def set_to_default(self): self.omx.kill() From eac855ee42f3b0c02dfa5fb30fd99159c1b14f96 Mon Sep 17 00:00:00 2001 From: Tim Caldwell Date: Thu, 12 Oct 2017 09:52:10 +1300 Subject: [PATCH 3/3] fix tab/space --- data_centre.py | 2 +- display_data.json | 2 +- omxdriver.pyc | Bin 13944 -> 14904 bytes 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data_centre.py b/data_centre.py index ceb5b44..4eca254 100644 --- a/data_centre.py +++ b/data_centre.py @@ -30,7 +30,7 @@ def setup_logging(): logger = setup_logging() ######## sets paths and constants ######## -PATH_TO_BROWSER = get_the_current_dir_path() #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() EMPTY_BANK = dict(name='',location='',length=-1,start=-1,end=-1) diff --git a/display_data.json b/display_data.json index c7da799..34c0d92 100644 --- a/display_data.json +++ b/display_data.json @@ -1 +1 @@ -[{"start": -1, "length": -1, "end": -1, "location": "/home/pi/pp_home/media/samplerloop3s3.mp4", "name": "samplerloop3s3.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "/home/pi/pp_home/media/5sec.mp4", "name": "5sec.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "/home/pi/pp_home/media/xthresh.mp4", "name": "xthresh.mp4"}, {"start": -1, "length": -1, "end": -1, "location": "/home/pi/pp_home/media/samplerloop3s2.mp4", "name": "samplerloop3s2.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": "/home/pi/pp_home/media/samplerloop3s2.mp4", "name": "samplerloop3s2.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": ""}] \ No newline at end of file +[{"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": ""}] \ No newline at end of file diff --git a/omxdriver.pyc b/omxdriver.pyc index 8e5e1d740d2167bd651eb26dfb69422fb9729dcc..fa44e5a751c028479ad40dc63ab32c16de68ee21 100644 GIT binary patch delta 1841 zcmey7v!jHa`7V*)CZGZKq(1B&vqQj<%H zW6Cm9QuBTC^9xdoVv6EZ5bCm2^@-^GZ zKP6l9WGlrRWT#P0rBbr>ZdEELTd%Y7K63SLmQcA%c3^GhQ4=IPX-+oLm_)9tC*Re` zBwKH+<~FkRYH95xTkkKeJLKx!{8l@R{8)<8olU-G9{n%m*EQlMR%F{eIm7fgx#2b0 H&CCb@AJwKV delta 881 zcmdl{@*{_x`7fgLVs0z1aq=+JJXKfVg!Yx@OxeK?k z$L$+g;$v)UvTGz U>E>2Abx!86JdVpfli93{08%g$82|tP