mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-07 08:50:07 +01:00
scrolling through banks , creating new banks and removing unused ones
This commit is contained in:
28
actions.py
28
actions.py
@@ -106,26 +106,38 @@ class Actions(object):
|
|||||||
def toggle_function(self):
|
def toggle_function(self):
|
||||||
self.message_handler.function_on = not self.message_handler.function_on
|
self.message_handler.function_on = not self.message_handler.function_on
|
||||||
|
|
||||||
|
def next_bank(self):
|
||||||
|
print('next bank')
|
||||||
|
self.update_bank(1)
|
||||||
|
|
||||||
|
def previous_bank(self):
|
||||||
|
self.update_bank(-1)
|
||||||
|
|
||||||
|
def update_bank(self, amount):
|
||||||
|
new_bank_number = self.data.update_bank_number(self.display.bank_number, amount)
|
||||||
|
print ('current number is : {} , new number is {} '.format(self.display.bank_number, new_bank_number))
|
||||||
|
self.display.bank_number = new_bank_number
|
||||||
|
|
||||||
def set_playing_sample_start_to_current_duration(self):
|
def set_playing_sample_start_to_current_duration(self):
|
||||||
current_slot = self.video_driver.current_player.slot_number
|
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
||||||
current_position = self.video_driver.current_player.get_position()
|
current_position = self.video_driver.current_player.get_position()
|
||||||
self.data.update_slot_start_to_this_time(self.display.bank_number, current_slot, current_position)
|
self.data.update_slot_start_to_this_time(current_bank, current_slot, current_position)
|
||||||
self.load_this_slot_into_next_player(current_slot)
|
self.load_this_slot_into_next_player(current_slot)
|
||||||
|
|
||||||
def clear_playing_sample_start_time(self):
|
def clear_playing_sample_start_time(self):
|
||||||
current_slot = self.video_driver.current_player.slot_number
|
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
||||||
self.data.update_slot_start_to_this_time(self.display.bank_number, current_slot, -1)
|
self.data.update_slot_start_to_this_time(current_bank, current_slot, -1)
|
||||||
self.load_this_slot_into_next_player(current_slot)
|
self.load_this_slot_into_next_player(current_slot)
|
||||||
|
|
||||||
def set_playing_sample_end_to_current_duration(self):
|
def set_playing_sample_end_to_current_duration(self):
|
||||||
current_slot = self.video_driver.current_player.slot_number
|
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
||||||
current_position = self.video_driver.current_player.get_position()
|
current_position = self.video_driver.current_player.get_position()
|
||||||
self.data.update_slot_end_to_this_time(self.display.bank_number, current_slot, current_position)
|
self.data.update_slot_end_to_this_time(current_bank, current_slot, current_position)
|
||||||
self.load_this_slot_into_next_player(current_slot)
|
self.load_this_slot_into_next_player(current_slot)
|
||||||
|
|
||||||
def clear_playing_sample_end_time(self):
|
def clear_playing_sample_end_time(self):
|
||||||
current_slot = self.video_driver.current_player.slot_number
|
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
||||||
self.data.update_slot_end_to_this_time(self.display.bank_number, current_slot, -1)
|
self.data.update_slot_end_to_this_time(current_bank, current_slot, -1)
|
||||||
self.load_this_slot_into_next_player(current_slot)
|
self.load_this_slot_into_next_player(current_slot)
|
||||||
|
|
||||||
def switch_display_to_hdmi(self):
|
def switch_display_to_hdmi(self):
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ NEXT_BANKSLOT_JSON = 'next_bankslot_number.json'
|
|||||||
SETTINGS_JSON = 'settings.json'
|
SETTINGS_JSON = 'settings.json'
|
||||||
KEYPAD_MAPPING = 'keypad_action_mapping.json'
|
KEYPAD_MAPPING = 'keypad_action_mapping.json'
|
||||||
EMPTY_SLOT = dict(name='', location='', length=-1, start=-1, end=-1)
|
EMPTY_SLOT = dict(name='', location='', length=-1, start=-1, end=-1)
|
||||||
|
EMPTY_BANK = [EMPTY_SLOT for i in range(10)]
|
||||||
PATH_TO_DATA_OBJECTS = '{}/json_objects/'.format(get_the_current_dir_path())
|
PATH_TO_DATA_OBJECTS = '{}/json_objects/'.format(get_the_current_dir_path())
|
||||||
|
|
||||||
def read_json(file_name):
|
def read_json(file_name):
|
||||||
@@ -71,10 +72,18 @@ class Data(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def clear_all_slots(bank_number):
|
def clear_all_slots(bank_number):
|
||||||
memory_bank = read_json(BANK_DATA_JSON)
|
memory_bank = read_json(BANK_DATA_JSON)
|
||||||
for index, slot in enumerate(memory_bank[bank_number]):
|
memory_bank[bank_number] = EMPTY_BANK
|
||||||
memory_bank[bank_number][index] = EMPTY_SLOT
|
|
||||||
update_json(BANK_DATA_JSON, memory_bank)
|
update_json(BANK_DATA_JSON, memory_bank)
|
||||||
|
|
||||||
|
def update_bank_number(self, current_bank_number, amount):
|
||||||
|
memory_bank = read_json(BANK_DATA_JSON)
|
||||||
|
if(memory_bank[-1] != EMPTY_BANK):
|
||||||
|
memory_bank.append(EMPTY_BANK)
|
||||||
|
elif(memory_bank[-1] == EMPTY_BANK and memory_bank[-2] == EMPTY_BANK):
|
||||||
|
memory_bank.pop()
|
||||||
|
update_json(BANK_DATA_JSON, memory_bank)
|
||||||
|
return (current_bank_number+amount)%(len(memory_bank))
|
||||||
|
|
||||||
def update_next_slot_number(self, bank_number, new_value):
|
def update_next_slot_number(self, bank_number, new_value):
|
||||||
memory_bank = read_json(BANK_DATA_JSON)
|
memory_bank = read_json(BANK_DATA_JSON)
|
||||||
if memory_bank[bank_number][new_value]['location'] == '':
|
if memory_bank[bank_number][new_value]['location'] == '':
|
||||||
@@ -111,7 +120,6 @@ class Data(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def split_bankslot_number(cls, slot_number):
|
def split_bankslot_number(cls, slot_number):
|
||||||
split = slot_number.split('-')
|
split = slot_number.split('-')
|
||||||
print(split)
|
|
||||||
is_bank_num_int , converted_bank_number = cls.try_convert_string_to_int(split[0])
|
is_bank_num_int , converted_bank_number = cls.try_convert_string_to_int(split[0])
|
||||||
is_slot_num_int , converted_slot_number = cls.try_convert_string_to_int(split[1])
|
is_slot_num_int , converted_slot_number = cls.try_convert_string_to_int(split[1])
|
||||||
return converted_bank_number, converted_slot_number
|
return converted_bank_number, converted_slot_number
|
||||||
@@ -147,11 +155,12 @@ class Data(object):
|
|||||||
|
|
||||||
context = dict(location=next_slot_details['location'], name=next_slot_details['name'],
|
context = dict(location=next_slot_details['location'], name=next_slot_details['name'],
|
||||||
length=next_slot_details['length'], start=start_value, end=end_value,
|
length=next_slot_details['length'], start=start_value, end=end_value,
|
||||||
slot_number=next_bankslot_number)
|
bankslot_number=next_bankslot_number)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def update_slot_start_to_this_time(self, bank_number, slot_number, position):
|
def update_slot_start_to_this_time(self, bank_number, slot_number, position):
|
||||||
memory_bank = read_json(BANK_DATA_JSON)
|
memory_bank = read_json(BANK_DATA_JSON)
|
||||||
|
print('bank_no {} , slot_no {} '.format(bank_number, slot_number))
|
||||||
memory_bank[bank_number][slot_number]['start'] = position
|
memory_bank[bank_number][slot_number]['start'] = position
|
||||||
update_json(BANK_DATA_JSON, memory_bank)
|
update_json(BANK_DATA_JSON, memory_bank)
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
[[{"start": -1, "location": "/media/pi/TIM1/videos_to_play/colour_pixel_01.mp4", "length": 49.28, "end": -1, "name": "colour_pixel_01.mp4"}, {"end": -1, "location": "/media/pi/TIM1/videos_to_play/colour_pixel_02.mp4", "length": 87.04, "start": -1, "name": "colour_pixel_02.mp4"}, {"location": "/media/pi/TIM1/teaser1.mp4", "length": 3.114, "end": -1, "start": -1, "name": "teaser1.mp4"}, {"end": -1, "location": "", "length": -1, "start": -1, "name": ""}, {"end": -1, "location": "", "length": -1, "start": -1, "name": ""}, {"end": -1, "location": "", "length": -1, "start": -1, "name": ""}, {"end": -1, "location": "", "length": -1, "start": -1, "name": ""}, {"end": -1, "location": "", "length": -1, "start": -1, "name": ""}, {"end": -1, "location": "", "length": -1, "start": -1, "name": ""}, {"end": -1, "location": "", "length": -1, "start": -1, "name": ""}]]
|
[[{"start": -1, "end": -1, "length": 49.28, "location": "/media/pi/TIM1/videos_to_play/colour_pixel_01.mp4", "name": "colour_pixel_01.mp4"}, {"start": -1, "end": -1, "length": 87.04, "location": "/media/pi/TIM1/videos_to_play/colour_pixel_02.mp4", "name": "colour_pixel_02.mp4"}, {"start": -1, "end": -1, "length": 3.114, "location": "/media/pi/TIM1/teaser1.mp4", "name": "teaser1.mp4"}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}], [{"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}, {"start": -1, "end": -1, "length": -1, "location": "", "name": ""}]]
|
||||||
@@ -31,10 +31,10 @@
|
|||||||
"DEFAULT": ["toggle_function"]
|
"DEFAULT": ["toggle_function"]
|
||||||
},
|
},
|
||||||
"j": {
|
"j": {
|
||||||
"DEFAULT": ["load_slot_0_into_next_player"]
|
"DEFAULT": ["load_slot_0_into_next_player","previous_bank"]
|
||||||
},
|
},
|
||||||
"k": {
|
"k": {
|
||||||
"DEFAULT": ["load_slot_1_into_next_player"]
|
"DEFAULT": ["load_slot_1_into_next_player","next_bank"]
|
||||||
},
|
},
|
||||||
"l": {
|
"l": {
|
||||||
"DEFAULT": ["load_slot_2_into_next_player","clear_all_slots"]
|
"DEFAULT": ["load_slot_2_into_next_player","clear_all_slots"]
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class Display(object):
|
|||||||
self.display_text.insert(END, '{:^4} {:<22} {:<4} {:<4} {:<4} \n'.format(
|
self.display_text.insert(END, '{:^4} {:<22} {:<4} {:<4} {:<4} \n'.format(
|
||||||
index, name_without_extension[0:22], self.format_time_value(slot['length']),
|
index, name_without_extension[0:22], self.format_time_value(slot['length']),
|
||||||
self.format_time_value(slot['start']), self.format_time_value(slot['end'])))
|
self.format_time_value(slot['start']), self.format_time_value(slot['end'])))
|
||||||
current_bank , current_slot = self.data.split_bankslot_number(self.video_driver.current_player.slot_number)
|
current_bank , current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
||||||
if current_bank is self.bank_number:
|
if current_bank is self.bank_number:
|
||||||
self.selected_list_index = current_slot
|
self.selected_list_index = current_slot
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class VideoDriver(object):
|
|||||||
|
|
||||||
def get_info_for_player_display(self):
|
def get_info_for_player_display(self):
|
||||||
if self.has_omx:
|
if self.has_omx:
|
||||||
return self.current_player.slot_number, self.current_player.status, self.next_player.slot_number, \
|
return self.current_player.bankslot_number, self.current_player.status, self.next_player.bankslot_number, \
|
||||||
self.next_player.status, self.current_player.get_position(), self.current_player.crop_length, \
|
self.next_player.status, self.current_player.get_position(), self.current_player.crop_length, \
|
||||||
self.current_player.start, self.current_player.end
|
self.current_player.start, self.current_player.end
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class video_player:
|
|||||||
self.omx_running = False
|
self.omx_running = False
|
||||||
self.status = 'N/A'
|
self.status = 'N/A'
|
||||||
self.total_length = 0.0
|
self.total_length = 0.0
|
||||||
self.slot_number = '*-*'
|
self.bankslot_number = '*-*'
|
||||||
self.start = -1.0
|
self.start = -1.0
|
||||||
self.end = -1.0
|
self.end = -1.0
|
||||||
self.crop_length = 0.0
|
self.crop_length = 0.0
|
||||||
@@ -108,7 +108,7 @@ class video_player:
|
|||||||
#self.total_length = next_context['length']
|
#self.total_length = next_context['length']
|
||||||
self.start = next_context['start']
|
self.start = next_context['start']
|
||||||
self.end = next_context['end']
|
self.end = next_context['end']
|
||||||
self.slot_number = next_context['slot_number']
|
self.bankslot_number = next_context['bankslot_number']
|
||||||
|
|
||||||
def toggle_pause(self):
|
def toggle_pause(self):
|
||||||
self.omx_player.play_pause()
|
self.omx_player.play_pause()
|
||||||
@@ -150,7 +150,7 @@ class fake_video_player:
|
|||||||
self.omx_running = False
|
self.omx_running = False
|
||||||
self.status = 'N/A'
|
self.status = 'N/A'
|
||||||
self.duration = 0
|
self.duration = 0
|
||||||
self.slot_number = '*-*'
|
self.bankslot_number = '*-*'
|
||||||
self.start = -1
|
self.start = -1
|
||||||
self.end = -1
|
self.end = -1
|
||||||
self.length = 0
|
self.length = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user