mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-11 19:00:04 +01:00
started experimenting with changing the rate of the video. def not finished , still having some issues to figure out
This commit is contained in:
16
actions.py
16
actions.py
@@ -115,9 +115,23 @@ class Actions(object):
|
||||
|
||||
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 increase_speed(self):
|
||||
new_rate = self.video_driver.current_player.change_rate(0.5)
|
||||
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
||||
self.data.update_slot_rate_to_this(current_bank, current_slot, new_rate)
|
||||
self.load_this_slot_into_next_player(current_slot)
|
||||
|
||||
def decrease_speed(self):
|
||||
new_rate = self.video_driver.current_player.change_rate(-0.5)
|
||||
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
||||
self.data.update_slot_rate_to_this(current_bank, current_slot, new_rate)
|
||||
self.load_this_slot_into_next_player(current_slot)
|
||||
|
||||
def print_speed(self):
|
||||
self.message_handler.set_message('INFO', 'the speed of current video is {}'.format(self.video_driver.current_player.omx_player.rate()))
|
||||
|
||||
def set_playing_sample_start_to_current_duration(self):
|
||||
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()
|
||||
|
||||
@@ -19,7 +19,7 @@ BANK_DATA_JSON = 'display_data.json'
|
||||
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_SLOT = dict(name='', location='', length=-1, start=-1, end=-1, rate=1)
|
||||
EMPTY_BANK = [EMPTY_SLOT for i in range(10)]
|
||||
PATH_TO_DATA_OBJECTS = '{}/json_objects/'.format(get_the_current_dir_path())
|
||||
|
||||
@@ -66,7 +66,7 @@ class Data(object):
|
||||
has_location, location = self._get_path_for_file(file_name)
|
||||
print('file_name:{},has_location:{}, location:{}'.format(file_name,has_location, location))
|
||||
length = self._get_length_for_file(location)
|
||||
new_slot = dict(name=file_name, location=location, length=length, start=-1, end=-1)
|
||||
new_slot = dict(name=file_name, location=location, length=length, start=-1, end=-1, rate=1)
|
||||
self._update_a_slots_data(bank_number, slot_number, new_slot)
|
||||
|
||||
@staticmethod
|
||||
@@ -154,7 +154,7 @@ class Data(object):
|
||||
length = next_slot_details['length']
|
||||
|
||||
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'], rate=next_slot_details['rate'], start=start_value, end=end_value,
|
||||
bankslot_number=next_bankslot_number)
|
||||
return context
|
||||
|
||||
@@ -169,6 +169,11 @@ class Data(object):
|
||||
memory_bank[bank_number][slot_number]['end'] = position
|
||||
update_json(BANK_DATA_JSON, memory_bank)
|
||||
|
||||
def update_slot_rate_to_this(self,bank_number, slot_number, rate):
|
||||
memory_bank = read_json(BANK_DATA_JSON)
|
||||
memory_bank[bank_number][slot_number]['rate'] = rate
|
||||
update_json(BANK_DATA_JSON, memory_bank)
|
||||
|
||||
def _get_length_for_file(self, path):
|
||||
if self.has_omx:
|
||||
temp_player = OMXPlayer(path, args=['--alpha', '0'], dbus_name='t.t')
|
||||
|
||||
@@ -1 +1 @@
|
||||
[[{"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": ""}]]
|
||||
[[{"rate": 3.5, "location": "/media/pi/TIM1/videos_to_play/colour_pixel_01.mp4", "length": 49.28, "end": -1, "start": -1, "name": "colour_pixel_01.mp4"}, {"rate": 1, "location": "/media/pi/TIM1/videos_to_play/long_spinning.mp4", "length": 804.245, "end": -1, "start": -1, "name": "long_spinning.mp4"}, {"rate": 0.5, "location": "/media/pi/TIM1/Test.mp4", "length": 599.585, "end": -1, "start": -1, "name": "Test.mp4"}, {"rate": 3.0, "location": "/media/pi/TIM1/teaser1.mp4", "length": 3.114, "end": -1, "start": -1, "name": "teaser1.mp4"}, {"rate": 0.5, "start": -1, "length": 3.114, "end": -1, "location": "/media/pi/TIM1/teaser1.mp4", "name": "teaser1.mp4"}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}], [{"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}, {"rate": 1, "location": "", "length": -1, "end": -1, "start": -1, "name": ""}]]
|
||||
@@ -40,13 +40,13 @@
|
||||
"DEFAULT": ["load_slot_2_into_next_player","clear_all_slots"]
|
||||
},
|
||||
"m": {
|
||||
"DEFAULT": ["load_slot_3_into_next_player"]
|
||||
"DEFAULT": ["load_slot_3_into_next_player","decrease_speed"]
|
||||
},
|
||||
"n": {
|
||||
"DEFAULT": ["load_slot_4_into_next_player"]
|
||||
"DEFAULT": ["load_slot_4_into_next_player","increase_speed"]
|
||||
},
|
||||
"o": {
|
||||
"DEFAULT": ["load_slot_5_into_next_player"]
|
||||
"DEFAULT": ["load_slot_5_into_next_player","print_speed"]
|
||||
},
|
||||
"p": {
|
||||
"DEFAULT": ["load_slot_6_into_next_player"]
|
||||
|
||||
@@ -1 +1 @@
|
||||
"0-1"
|
||||
"0-3"
|
||||
@@ -75,13 +75,13 @@ class Display(object):
|
||||
bank_data = self.data.get_sampler_data()[self.bank_number]
|
||||
self.display_text.insert(END, '------------------ <SAMPLER> ------------------ \n')
|
||||
self.display_text.tag_add("DISPLAY_MODE", 4.19, 4.29)
|
||||
self.display_text.insert(END, '{:^6} {:<20} {:<4} {:<4} {:<4} \n'.format(
|
||||
'{}-slot'.format(self.bank_number), 'name', 'length', 'start', 'end'))
|
||||
self.display_text.insert(END, '{:^6} {:<16} {:<4} {:<4} {:<4} {:<4} \n'.format(
|
||||
'{}-slot'.format(self.bank_number), 'name', 'length', 'start', 'end', 'rate'))
|
||||
for index, slot in enumerate(bank_data):
|
||||
name_without_extension = slot['name'].rsplit('.',1)[0]
|
||||
self.display_text.insert(END, '{:^4} {:<22} {:<4} {:<4} {:<4} \n'.format(
|
||||
self.display_text.insert(END, '{:^4} {:<18} {:<4} {:<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'])))
|
||||
self.format_time_value(slot['start']), self.format_time_value(slot['end']), slot['rate']))
|
||||
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
|
||||
|
||||
@@ -17,6 +17,7 @@ class video_player:
|
||||
self.bankslot_number = '*-*'
|
||||
self.start = -1.0
|
||||
self.end = -1.0
|
||||
self.rate = 1
|
||||
self.crop_length = 0.0
|
||||
self.location = ''
|
||||
self.load_attempts = 0
|
||||
@@ -53,6 +54,8 @@ class video_player:
|
||||
if self.start > 0.5:
|
||||
self.set_position(self.start - 0.5)
|
||||
self.pause_at_start()
|
||||
print('set rate to {}'.format(self.rate))
|
||||
self.omx_player.set_rate(self.rate)
|
||||
self.load_attempts = 0
|
||||
return True
|
||||
except ValueError:
|
||||
@@ -109,6 +112,7 @@ class video_player:
|
||||
self.start = next_context['start']
|
||||
self.end = next_context['end']
|
||||
self.bankslot_number = next_context['bankslot_number']
|
||||
self.rate = next_context['rate']
|
||||
|
||||
def toggle_pause(self):
|
||||
self.omx_player.play_pause()
|
||||
@@ -123,6 +127,17 @@ class video_player:
|
||||
else:
|
||||
self.message_handler.set_message('INFO', 'can not seek outside range')
|
||||
|
||||
def change_rate(self, amount):
|
||||
new_rate = self.rate + amount
|
||||
if (new_rate > self.omx_player.minimum_rate() and new_rate < self.omx_player.maximum_rate()):
|
||||
updated_speed = self.omx_player.set_rate(new_rate)
|
||||
self.rate = new_rate
|
||||
print('max rate {} , min rate {} '.format(self.omx_player.maximum_rate() ,self.omx_player.minimum_rate()))
|
||||
return new_rate
|
||||
else:
|
||||
self.message_handler.set_message('INFO', 'can not set speed outside of range')
|
||||
return self.rate
|
||||
|
||||
def set_position(self, position):
|
||||
self.omx_player.set_position(position)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user