diff --git a/data_centre.py b/data_centre.py index dc3893d..25329c5 100644 --- a/data_centre.py +++ b/data_centre.py @@ -5,11 +5,19 @@ import os from random import randint import time import inspect + #from ffprobe import FFProbe +try: + from omxplayer.player import OMXPlayer + has_omx = True +except: + has_omx = False +print('has omx:{}'.format(has_omx)) current_message = None + def set_message(message): global current_message print('trying to set message') @@ -179,9 +187,7 @@ def create_new_bank_mapping(bank_number,file_name,memory_bank=[]): update_a_banks_data(bank_number, new_bank, memory_bank) def get_length_for_file(location): - #video_length = FFProbe(location).streams[0].duration - #print(video_length) - return 0 + return get_duration_from_path(location) def get_path_for_file(file_name): ######## returns full path for a given file name ######## @@ -338,3 +344,10 @@ def update_next_bank_number(new_value): else: update_json(NEXT_BANK_JSON, new_value) +def get_duration_from_path(path): + temp_player = OMXPlayer(path, args=['--alpha', '0'], dbus_name='t.t') + duration = temp_player.duration() + temp_player.quit() + return duration + + diff --git a/data_objects/display_data.json b/data_objects/display_data.json index 122f81b..4caef6b 100644 --- a/data_objects/display_data.json +++ b/data_objects/display_data.json @@ -1,107 +1 @@ -[ - { - "start": -1, - "length": 4, - "end": -1, - "name": "samplerloop3s.mp4", - "location": "/media/pi/TIM1/samplerloop3s.mp4" - }, - { - "start": -1, - "length": 3, - "end": -1, - "name": "teaser1.mp4", - "location": "/media/pi/TIM1/teaser1.mp4" - }, - { - "start": -1, - "length": 3, - "end": -1, - "name": "teaser2.mp4", - "location": "/media/pi/TIM1/teaser2.mp4" - }, - { - "start": -1, - "length": 3, - "end": -1, - "name": "teaser3.mp4", - "location": "/media/pi/TIM1/teaser3.mp4" - }, - { - "start": -1, - "length": 2, - "end": -1, - "name": "teaser4.mp4", - "location": "/media/pi/TIM1/teaser4.mp4" - }, - { - "start": -1, - "length": 600, - "end": -1, - "name": "Test.mp4", - "location": "/media/pi/TIM1/Test.mp4" - }, - { - "start": -1, - "length": 26, - "end": -1, - "name": "01_trashpalaceintro.mp4", - "location": "/media/pi/TIM1/TRASHPALACEVIDEOS/01_trashpalaceintro.mp4" - }, - { - "start": 10, - "length": 49, - "end": 15, - "name": "colour_pixel_01.mp4", - "location": "/media/pi/TIM1/videos_to_play/colour_pixel_01.mp4" - }, - { - "start": -1, - "end": -1, - "length": 0, - "name": "teaser1.mp4", - "location": "/media/pi/TIM1/teaser1.mp4" - }, - { - "start": -1, - "end": -1, - "length": 0, - "name": "samplerloop3s2.mp4", - "location": "/media/pi/TIM1/samplerloop3s2.mp4" - }, - { - "start": -1, - "length": -1, - "end": -1, - "name": "", - "location": "" - }, - { - "start": -1, - "length": -1, - "end": -1, - "name": "", - "location": "" - }, - { - "start": -1, - "length": -1, - "end": -1, - "name": "", - "location": "" - }, - { - "start": -1, - "length": -1, - "end": -1, - "name": "", - "location": "" - }, - { - "start": -1, - "length": -1, - "end": -1, - "name": "", - "location": "" - } -] +[{"start": -1, "end": -1, "location": "/media/pi/TIM1/samplerloop3s.mp4", "length": 4, "name": "samplerloop3s.mp4"}, {"start": -1, "end": -1, "location": "/media/pi/TIM1/teaser1.mp4", "length": 3, "name": "teaser1.mp4"}, {"start": -1, "end": -1, "location": "/media/pi/TIM1/teaser2.mp4", "length": 3, "name": "teaser2.mp4"}, {"start": -1, "end": -1, "location": "/media/pi/TIM1/teaser3.mp4", "length": 3, "name": "teaser3.mp4"}, {"start": -1, "end": -1, "location": "/media/pi/TIM1/teaser4.mp4", "length": 2, "name": "teaser4.mp4"}, {"start": -1, "end": -1, "location": "/media/pi/TIM1/Test.mp4", "length": 600, "name": "Test.mp4"}, {"start": -1, "end": -1, "location": "/media/pi/TIM1/TRASHPALACEVIDEOS/01_trashpalaceintro.mp4", "length": 26, "name": "01_trashpalaceintro.mp4"}, {"start": 10, "end": 15, "location": "/media/pi/TIM1/videos_to_play/colour_pixel_01.mp4", "length": 49, "name": "colour_pixel_01.mp4"}, {"start": -1, "end": -1, "location": "/media/pi/TIM1/teaser1.mp4", "length": 0, "name": "teaser1.mp4"}, {"start": -1, "end": -1, "location": "/media/pi/TIM1/samplerloop3s2.mp4", "length": 0, "name": "samplerloop3s2.mp4"}, {"start": -1, "end": -1, "location": "/media/pi/TIM1/videos_to_play/colour_pixel_02.mp4", "length": 87.04, "name": "colour_pixel_02.mp4"}, {"start": -1, "end": -1, "location": "/media/pi/TIM1/videos_to_play/long_spinning.mp4", "length": 804.245, "name": "long_spinning.mp4"}, {"start": -1, "end": -1, "location": "", "length": -1, "name": ""}, {"start": -1, "end": -1, "location": "", "length": -1, "name": ""}, {"start": -1, "end": -1, "location": "", "length": -1, "name": ""}] \ No newline at end of file diff --git a/user_input/numpad_input.py b/user_input/numpad_input.py index 6357f84..acaf69d 100644 --- a/user_input/numpad_input.py +++ b/user_input/numpad_input.py @@ -24,7 +24,7 @@ class NumpadInput(object): elif event.char == '.': self.on_dot_press() - def on_backspace_press(self): + def on_backspace_press(self, event): if self.display.display_mode == 'BROWSER': self.actions.enter_on_browser_selection() elif self.display.display_mode == 'LOOPER': diff --git a/video_centre/video_player.py b/video_centre/video_player.py index 17a9f3a..15f30f5 100644 --- a/video_centre/video_player.py +++ b/video_centre/video_player.py @@ -42,7 +42,6 @@ class video_player: def pause_at_start(self): position = self.get_position() start_threshold = self.start - 0.05 - print('position:{} threshold:{}'.format(position, start_threshold)) if(position > start_threshold): self.status = 'LOADED' self.player.pause() @@ -122,3 +121,5 @@ class fake_video_player: self.length = 0 self.location = '' + +