scrolling through banks , creating new banks and removing unused ones

This commit is contained in:
langolierz
2018-02-23 23:00:00 +00:00
parent 495ec8a5e8
commit 715560df41
7 changed files with 41 additions and 20 deletions

View File

@@ -106,26 +106,38 @@ class Actions(object):
def toggle_function(self):
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):
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()
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)
def clear_playing_sample_start_time(self):
current_slot = self.video_driver.current_player.slot_number
self.data.update_slot_start_to_this_time(self.display.bank_number, current_slot, -1)
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
self.data.update_slot_start_to_this_time(current_bank, current_slot, -1)
self.load_this_slot_into_next_player(current_slot)
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()
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)
def clear_playing_sample_end_time(self):
current_slot = self.video_driver.current_player.slot_number
self.data.update_slot_end_to_this_time(self.display.bank_number, current_slot, -1)
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
self.data.update_slot_end_to_this_time(current_bank, current_slot, -1)
self.load_this_slot_into_next_player(current_slot)
def switch_display_to_hdmi(self):

View File

@@ -20,6 +20,7 @@ NEXT_BANKSLOT_JSON = 'next_bankslot_number.json'
SETTINGS_JSON = 'settings.json'
KEYPAD_MAPPING = 'keypad_action_mapping.json'
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())
def read_json(file_name):
@@ -71,10 +72,18 @@ class Data(object):
@staticmethod
def clear_all_slots(bank_number):
memory_bank = read_json(BANK_DATA_JSON)
for index, slot in enumerate(memory_bank[bank_number]):
memory_bank[bank_number][index] = EMPTY_SLOT
memory_bank[bank_number] = EMPTY_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):
memory_bank = read_json(BANK_DATA_JSON)
if memory_bank[bank_number][new_value]['location'] == '':
@@ -111,7 +120,6 @@ class Data(object):
@classmethod
def split_bankslot_number(cls, slot_number):
split = slot_number.split('-')
print(split)
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])
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'],
length=next_slot_details['length'], start=start_value, end=end_value,
slot_number=next_bankslot_number)
bankslot_number=next_bankslot_number)
return context
def update_slot_start_to_this_time(self, bank_number, slot_number, position):
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
update_json(BANK_DATA_JSON, memory_bank)

View File

@@ -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": ""}]]

View File

@@ -31,10 +31,10 @@
"DEFAULT": ["toggle_function"]
},
"j": {
"DEFAULT": ["load_slot_0_into_next_player"]
"DEFAULT": ["load_slot_0_into_next_player","previous_bank"]
},
"k": {
"DEFAULT": ["load_slot_1_into_next_player"]
"DEFAULT": ["load_slot_1_into_next_player","next_bank"]
},
"l": {
"DEFAULT": ["load_slot_2_into_next_player","clear_all_slots"]

View File

@@ -82,7 +82,7 @@ class Display(object):
self.display_text.insert(END, '{:^4} {:<22} {:<4} {:<4} {:<4} \n'.format(
index, name_without_extension[0:22], self.format_time_value(slot['length']),
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:
self.selected_list_index = current_slot
else:

View File

@@ -87,7 +87,7 @@ class VideoDriver(object):
def get_info_for_player_display(self):
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.current_player.start, self.current_player.end
else:

View File

@@ -14,7 +14,7 @@ class video_player:
self.omx_running = False
self.status = 'N/A'
self.total_length = 0.0
self.slot_number = '*-*'
self.bankslot_number = '*-*'
self.start = -1.0
self.end = -1.0
self.crop_length = 0.0
@@ -108,7 +108,7 @@ class video_player:
#self.total_length = next_context['length']
self.start = next_context['start']
self.end = next_context['end']
self.slot_number = next_context['slot_number']
self.bankslot_number = next_context['bankslot_number']
def toggle_pause(self):
self.omx_player.play_pause()
@@ -150,7 +150,7 @@ class fake_video_player:
self.omx_running = False
self.status = 'N/A'
self.duration = 0
self.slot_number = '*-*'
self.bankslot_number = '*-*'
self.start = -1
self.end = -1
self.length = 0