diff --git a/data_centre.py b/data_centre.py index a84579c..4698155 100644 --- a/data_centre.py +++ b/data_centre.py @@ -167,6 +167,7 @@ def create_new_bank_mapping(bank_number,file_name,memory_bank=[]): def get_length_for_file(location): video_length = FFProbe(location).streams[0].duration + print video_length return int(round(float(video_length))) def get_path_for_file(file_name): diff --git a/display_centre.py b/display_centre.py index aba450e..7fcd700 100644 --- a/display_centre.py +++ b/display_centre.py @@ -24,12 +24,10 @@ browser_index = 0 tk = Tk() - frame = Frame(tk, width=500, height=400) video_driver = video_centre.video_driver(frame) - # our data store data_object = data_centre.data() @@ -37,6 +35,7 @@ browser_list = data_object.get_browser_data_for_display() bank_info = data_centre.get_all_looper_data_for_display() +current_message = None # terminal_font = Font(family="Terminal", size=12) # terminal_font_bold = Font(family="Terminal", size=12, weight='bold') # titles.configure(font=terminal_font_bold) @@ -55,6 +54,7 @@ def load_display(display): else: load_looper(display) #load_divider(display) + display.pack() @@ -88,6 +88,14 @@ def load_looper(display): display.insert(END, '{:>3} {:>10} {:>3} {:>3} {:>3} \n'.format( bank[0], bank[1], bank[2], bank[3], bank[4])) +def load_message(display): + display.insert(END, 'INFO: {}'.format(current_message)) + display.tag_add("ERROR_MESSAGE", 14.0, 15.0) + tk.after(4000,clear_message) + +def clear_message(): + global current_message + current_message = None def get_text_for_video_display(): now_bank, now_status, next_bank, next_status, duration, video_length = video_driver.get_info_for_video_display() @@ -182,32 +190,52 @@ def refresh_display(): display = Text(tk, bg="black", fg="white", font=('courier', 14)) display.tag_configure("SELECT", background="white", foreground="black") display.tag_configure("TITLE", background="black", foreground="red") +display.tag_configure("ERROR_MESSAGE", background="red", foreground="black") +display.tag_configure("INFO_MESSAGE", background="blue", foreground="black") display.tag_configure("PLAYER_INFO", background="black", foreground="yellow") load_display(display) select_current_browser_index() +def num_lock_key(event): + global display_mode + if display_mode == "BROWSER": + display_mode = "LOOPER" + else: + display_mode = "BROWSER" + refresh_display() + def key(event): print event.char + ## '/' clear all banks if event.char == '/': print 'it\'s cleared!' data_centre.clear_all_banks() refresh_display() - - if event.char == '.': + ## '.' quits r_e_c_u_r + elif event.char == '.': if video_centre.has_omx: video_driver.exit_all_players() tk.destroy() - - if event.char in ['0', '1', '2', '3', '4', '5', '6', '7']: + ## 'num' sets current selection to bank number num + elif event.char in ['0', '1', '2', '3', '4', '5', '6', '7']: data_centre.update_next_bank_number(int(event.char)) # video_driver.next_player.reload_content() + ## 'enter' sets manual next flag elif event.char in ['\r']: video_driver.manual_next = True - elif(event.char in ['.']): - # code for killswitch - sys.exit() + ## 'm' switches display mode + elif(event.char in ['m']): + global display_mode + if display_mode == "BROWSER": + display_mode = "LOOPER" + else: + display_mode = "BROWSER" + refresh_display() + ## 'l' pauses/unpauses the video + elif(event.char in ['l']): + video_driver.current_player.toggle_pause() def up_key(event): @@ -222,29 +250,28 @@ def down_key(event): global browser_index global browser_start_index -def num_lock_key(event): - global display_mode - if display_mode == "BROWSER": - display_mode = "LOOPER" - else: - display_mode = "BROWSER" - refresh_display() + def backspace_key(event): - global browser_index - global data_object - global browser_start_index - global browser_list - if display_mode == "BROWSER": - is_file, name = data_centre.extract_file_type_and_name_from_browser_format( - browser_list[browser_index + browser_start_index][0]) - if is_file: - data_centre.create_new_bank_mapping_in_first_open(name) - else: - data_object.update_open_folders(name) - data_object.rewrite_browser_list() - browser_list = data_object.get_browser_data_for_display() - refresh_display() + try: + global browser_index + global data_object + global browser_start_index + global browser_list + global current_message + if display_mode == "BROWSER": + is_file, name = data_centre.extract_file_type_and_name_from_browser_format( + browser_list[browser_index + browser_start_index][0]) + if is_file: + data_centre.create_new_bank_mapping_in_first_open(name) + else: + data_object.update_open_folders(name) + data_object.rewrite_browser_list() + browser_list = data_object.get_browser_data_for_display() + refresh_display() + except Exception as e: + print 'the current message is: {}'.format(e.message) + current_message = e.message def update_screen(): @@ -263,8 +290,13 @@ display.bind("", backspace_key) display.bind("", num_lock_key) display.bind("", callback) + frame.pack() tk.attributes("-fullscreen", True) tk.after(1000, update_screen) -tk.mainloop() + +try: + tk.mainloop() +except: + current_message = traceback.print_tb(exc_traceback, limit=1, file=sys.stdout) diff --git a/display_data.json b/display_data.json index d26d6bf..612c886 100644 --- a/display_data.json +++ b/display_data.json @@ -1 +1,2 @@ -[{"start": -1, "length": 4, "end": -1, "location": "/media/pi/TIM1/samplerloop3s.mp4", "name": "samplerloop3s.mp4"}, {"start": -1, "length": 5, "end": -1, "location": "/media/pi/TIM1/samplerloop3s2.mp4", "name": "samplerloop3s2.mp4"}, {"start": -1, "length": 3, "end": -1, "location": "/media/pi/TIM1/samplerloop3s3.mp4", "name": "samplerloop3s3.mp4"}, {"start": -1, "length": 3, "end": -1, "location": "/media/pi/TIM1/samplerloop3s3.mp4", "name": "samplerloop3s3.mp4"}, {"start": -1, "length": 3, "end": -1, "location": "/media/pi/TIM1/samplerloop3s3.mp4", "name": "samplerloop3s3.mp4"}, {"start": -1, "length": 26, "end": -1, "location": "/media/pi/TIM1/TRASHPALACEVIDEOS/01_trashpalaceintro.mp4", "name": "01_trashpalaceintro.mp4"}, {"start": -1, "length": 97, "end": -1, "location": "/media/pi/TIM1/TRASHPALACEVIDEOS/04_THEORY_OF_OBSCURITY.mp4", "name": "04_THEORY_OF_OBSCURITY.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": ""}] \ No newline at end of file +[{"start": -1, "length": 4, "end": -1, "location": "/media/pi/TIM1/samplerloop3s.mp4", "name": "samplerloop3s.mp4"}, {"start": -1, "length": 5, "end": -1, "location": "/media/pi/TIM1/samplerloop3s2.mp4", "name": "samplerloop3s2.mp4"}, {"start": -1, "length": 3, "end": -1, "location": "/media/pi/TIM1/samplerloop3s3.mp4", "name": "samplerloop3s3.mp4"}, {"start": -1, "length": 3, "end": -1, "location": "/media/pi/TIM1/samplerloop3s3.mp4", "name": "samplerloop3s3.mp4"}, {"start": -1, "length": 3, "end": -1, "location": "/media/pi/TIM1/samplerloop3s3.mp4", "name": "samplerloop3s3.mp4"}, {"start": -1, "length": 26, "end": -1, "location": "/media/pi/TIM1/TRASHPALACEVIDEOS/01_trashpalaceintro.mp4", "name": "01_trashpalaceintro.mp4"}, {"start": -1, "length": 97, "end": -1, "location": "/media/pi/TIM1/TRASHPALACEVIDEOS/04_THEORY_OF_OBSCURITY.mp4", "name": "04_THEORY_OF_OBSCURITY.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": ""}] + diff --git a/next_bank_number.json b/next_bank_number.json index 62f9457..573541a 100644 --- a/next_bank_number.json +++ b/next_bank_number.json @@ -1 +1 @@ -6 \ No newline at end of file +0 diff --git a/video_centre.py b/video_centre.py index 90beb4c..ade280d 100644 --- a/video_centre.py +++ b/video_centre.py @@ -174,8 +174,19 @@ class video_player(object): self.omx.stop() self.omx = OMXDriver(self.widget, '') - def pause_content(self): - self.status = 'PAUSED' + def toggle_pause(self): + is_paused = self.omx.omxplayer_is_paused() + print is_paused + if is_paused == 'RUNNING': + if self.omx.send_pause(): + self.status = 'PAUSED' + return + elif is_paused == 'PAUSED': + if self.omx.send_unpause(): + self.status = 'PLAYING' + return + print 'failed to toggle pause (this needs to be in message)' + # tk = Tk()