mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-05 16:00:06 +01:00
experimental work with dif sampler playmodes
This commit is contained in:
@@ -93,6 +93,9 @@ class Actions(object):
|
|||||||
def toggle_pause_on_player(self):
|
def toggle_pause_on_player(self):
|
||||||
self.video_driver.current_player.toggle_pause()
|
self.video_driver.current_player.toggle_pause()
|
||||||
|
|
||||||
|
def toggle_show_on_player(self):
|
||||||
|
self.video_driver.current_player.toggle_show()
|
||||||
|
|
||||||
def seek_forward_on_player(self):
|
def seek_forward_on_player(self):
|
||||||
self.video_driver.current_player.seek(30)
|
self.video_driver.current_player.seek(30)
|
||||||
|
|
||||||
@@ -177,6 +180,9 @@ class Actions(object):
|
|||||||
output_range = max_param - min_param
|
output_range = max_param - min_param
|
||||||
return int(( cc_value / 127 ) * output_range + min_param)
|
return int(( cc_value / 127 ) * output_range + min_param)
|
||||||
|
|
||||||
|
def update_video_settings(self, setting_value):
|
||||||
|
self.video_driver.update_video_settings()
|
||||||
|
|
||||||
def change_output_mode(self, setting_value):
|
def change_output_mode(self, setting_value):
|
||||||
if setting_value == 'hdmi':
|
if setting_value == 'hdmi':
|
||||||
subprocess.call(['tvservice', '-p'])
|
subprocess.call(['tvservice', '-p'])
|
||||||
|
|||||||
@@ -18,9 +18,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"end": -1,
|
"end": -1,
|
||||||
"length": -1,
|
"length": 4.714,
|
||||||
"location": "",
|
"location": "/media/pi/5EB5-664C/recur test videos/samplerloop3s2.mp4",
|
||||||
"name": "",
|
"name": "samplerloop3s2.mp4",
|
||||||
"rate": 1,
|
"rate": 1,
|
||||||
"start": -1
|
"start": -1
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
"c": {
|
"c": {
|
||||||
"NAV_BROWSER": ["enter_on_browser_selection"],
|
"NAV_BROWSER": ["enter_on_browser_selection"],
|
||||||
"PLAYER": ["toggle_pause_on_player"],
|
"PLAYER": ["toggle_pause_on_player","toggle_show_on_player"],
|
||||||
"NAV_SETTINGS": ["enter_on_settings_selection"]
|
"NAV_SETTINGS": ["enter_on_settings_selection"]
|
||||||
},
|
},
|
||||||
"d": {
|
"d": {
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
},
|
},
|
||||||
"sampler": {
|
"sampler": {
|
||||||
"ACTION_GATED": {
|
"ACTION_GATED": {
|
||||||
"action": null,
|
"action": "update_video_settings",
|
||||||
"options": [
|
"options": [
|
||||||
"on",
|
"on",
|
||||||
"off"
|
"off"
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
"value": ""
|
"value": ""
|
||||||
},
|
},
|
||||||
"FIXED_LENGTH_MODE": {
|
"FIXED_LENGTH_MODE": {
|
||||||
"action": "cycle_setting_options",
|
"action": "update_video_settings",
|
||||||
"options": [
|
"options": [
|
||||||
"on",
|
"on",
|
||||||
"off"
|
"off"
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
"value": "off"
|
"value": "off"
|
||||||
},
|
},
|
||||||
"LOAD_NEXT": {
|
"LOAD_NEXT": {
|
||||||
"action": null,
|
"action": "update_video_settings",
|
||||||
"options": [
|
"options": [
|
||||||
"now",
|
"now",
|
||||||
"random",
|
"random",
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
"value": "now"
|
"value": "now"
|
||||||
},
|
},
|
||||||
"ON_ACTION": {
|
"ON_ACTION": {
|
||||||
"action": null,
|
"action": "update_video_settings",
|
||||||
"options": [
|
"options": [
|
||||||
"pause/hide",
|
"pause/hide",
|
||||||
"pause/show",
|
"pause/show",
|
||||||
@@ -120,35 +120,33 @@
|
|||||||
"value": "pause/hide"
|
"value": "pause/hide"
|
||||||
},
|
},
|
||||||
"ON_FINISH": {
|
"ON_FINISH": {
|
||||||
"action": null,
|
"action": "update_video_settings",
|
||||||
"options": [
|
"options": [
|
||||||
"nothing",
|
"nothing",
|
||||||
"switch"
|
"switch"
|
||||||
],
|
],
|
||||||
"value": "pause/hide"
|
"value": "switch"
|
||||||
},
|
},
|
||||||
"ON_LOAD": {
|
"ON_LOAD": {
|
||||||
"action": null,
|
"action": "update_video_settings",
|
||||||
"options": [
|
"options": [
|
||||||
"pause/hide",
|
"hide",
|
||||||
"pause/show",
|
"show"
|
||||||
"play/hide",
|
|
||||||
"play/show"
|
|
||||||
],
|
],
|
||||||
"value": "pause/hide"
|
"value": "show"
|
||||||
},
|
},
|
||||||
"ON_START": {
|
"ON_START": {
|
||||||
"action": null,
|
"action": "update_video_settings",
|
||||||
"options": [
|
"options": [
|
||||||
"pause/hide",
|
"pause/hide",
|
||||||
"pause/show",
|
"pause/show",
|
||||||
"play/hide",
|
"play/hide",
|
||||||
"play/show"
|
"play/show"
|
||||||
],
|
],
|
||||||
"value": "pause/hide"
|
"value": "play/show"
|
||||||
},
|
},
|
||||||
"RAND_START_MODE": {
|
"RAND_START_MODE": {
|
||||||
"action": "cycle_setting_options",
|
"action": "update_video_settings",
|
||||||
"options": [
|
"options": [
|
||||||
"on",
|
"on",
|
||||||
"off"
|
"off"
|
||||||
|
|||||||
@@ -15,13 +15,26 @@ class VideoDriver(object):
|
|||||||
self.next_player = VideoPlayer(self.root, self.message_handler, self.data, 'c.c')
|
self.next_player = VideoPlayer(self.root, self.message_handler, self.data, 'c.c')
|
||||||
self.root.after(self.delay, self.begin_playing)
|
self.root.after(self.delay, self.begin_playing)
|
||||||
|
|
||||||
|
self.switch_on_finish = self.data.settings['sampler']['ON_FINISH']['value'] == 'switch'
|
||||||
|
self.play_on_start = 'play' in self.data.settings['sampler']['ON_START']['value']
|
||||||
|
self.show_on_start = 'show' in self.data.settings['sampler']['ON_START']['value']
|
||||||
|
self.play_on_load = 'play' in self.data.settings['sampler']['ON_LOAD']['value']
|
||||||
|
self.show_on_load = 'show' in self.data.settings['sampler']['ON_LOAD']['value']
|
||||||
|
|
||||||
|
def update_video_settings(self):
|
||||||
|
self.switch_on_finish = self.data.settings['sampler']['ON_FINISH']['value'] == 'switch'
|
||||||
|
self.play_on_start = 'play' in self.data.settings['sampler']['ON_START']['value']
|
||||||
|
self.show_on_start = 'show' in self.data.settings['sampler']['ON_START']['value']
|
||||||
|
self.show_on_load = 'show' == self.data.settings['sampler']['ON_LOAD']['value']
|
||||||
|
|
||||||
|
|
||||||
def print_status(self):
|
def print_status(self):
|
||||||
print('l({}):{}, c({}):{}, n({}):{}'.format(self.last_player.name, self.last_player.status, self.current_player.name, self.current_player.status, self.next_player.name, self.next_player.status,))
|
print('l({}):{}, c({}):{}, n({}):{}'.format(self.last_player.name, self.last_player.status, self.current_player.name, self.current_player.status, self.next_player.name, self.next_player.status,))
|
||||||
self.root.after(1000,self.print_status)
|
self.root.after(1000,self.print_status)
|
||||||
|
|
||||||
def begin_playing(self):
|
def begin_playing(self):
|
||||||
# TODO: the first clip will be a demo
|
# TODO: the first clip will be a demo
|
||||||
if self.current_player.try_load():
|
if self.current_player.try_load(self.show_on_load):
|
||||||
self.in_first_load_cycle = True
|
self.in_first_load_cycle = True
|
||||||
self.wait_for_first_load()
|
self.wait_for_first_load()
|
||||||
else:
|
else:
|
||||||
@@ -50,9 +63,11 @@ class VideoDriver(object):
|
|||||||
#self.last_player.exit()
|
#self.last_player.exit()
|
||||||
|
|
||||||
def play_video(self):
|
def play_video(self):
|
||||||
self.current_player.play()
|
print(self.play_on_start)
|
||||||
|
if self.play_on_start:
|
||||||
|
self.current_player.play(self.show_on_start)
|
||||||
self.last_player.exit()
|
self.last_player.exit()
|
||||||
self.next_player.try_load()
|
self.next_player.try_load(self.show_on_load)
|
||||||
self.in_current_playing_cycle = True
|
self.in_current_playing_cycle = True
|
||||||
self.wait_for_next_cycle()
|
self.wait_for_next_cycle()
|
||||||
|
|
||||||
@@ -61,7 +76,8 @@ class VideoDriver(object):
|
|||||||
if self.current_player.is_finished():
|
if self.current_player.is_finished():
|
||||||
self.in_current_playing_cycle = False
|
self.in_current_playing_cycle = False
|
||||||
self.in_next_load_cycle = True
|
self.in_next_load_cycle = True
|
||||||
self.switch_if_next_is_loaded()
|
if self.switch_on_finish:
|
||||||
|
self.switch_if_next_is_loaded()
|
||||||
else:
|
else:
|
||||||
self.root.after(self.delay, self.wait_for_next_cycle)
|
self.root.after(self.delay, self.wait_for_next_cycle)
|
||||||
|
|
||||||
@@ -86,3 +102,6 @@ class VideoDriver(object):
|
|||||||
self.next_player.exit()
|
self.next_player.exit()
|
||||||
self.current_player.exit()
|
self.current_player.exit()
|
||||||
|
|
||||||
|
def reload_next_player(self):
|
||||||
|
self.next_player.reload(self,show_on_load)
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,13 @@ class VideoPlayer:
|
|||||||
self.location = ''
|
self.location = ''
|
||||||
self.load_attempts = 0
|
self.load_attempts = 0
|
||||||
|
|
||||||
def try_load(self):
|
self.show_toggle_on = True
|
||||||
|
|
||||||
|
def try_load(self, show):
|
||||||
load_attempts = 0
|
load_attempts = 0
|
||||||
while(load_attempts < 2):
|
while(load_attempts < 2):
|
||||||
load_attempts = load_attempts + 1
|
load_attempts = load_attempts + 1
|
||||||
if self.load():
|
if self.load(show):
|
||||||
print('load success')
|
print('load success')
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@@ -32,7 +34,7 @@ class VideoPlayer:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def load(self):
|
def load(self, show):
|
||||||
try:
|
try:
|
||||||
self.get_context_for_player()
|
self.get_context_for_player()
|
||||||
is_dev_mode, first_screen_arg, second_screen_arg = self.set_screen_size_for_dev_mode()
|
is_dev_mode, first_screen_arg, second_screen_arg = self.set_screen_size_for_dev_mode()
|
||||||
@@ -52,7 +54,7 @@ class VideoPlayer:
|
|||||||
print('{}: the duration is {}'.format(self.name, self.total_length))
|
print('{}: the duration is {}'.format(self.name, self.total_length))
|
||||||
if self.start > 0.9:
|
if self.start > 0.9:
|
||||||
self.set_position(self.start - 0.9)
|
self.set_position(self.start - 0.9)
|
||||||
self.pause_at_start()
|
self.pause_at_start(show)
|
||||||
#print('set rate to {}'.format(self.rate))
|
#print('set rate to {}'.format(self.rate))
|
||||||
#self.omx_player.set_rate(self.rate)
|
#self.omx_player.set_rate(self.rate)
|
||||||
#self.load_attempts = 0
|
#self.load_attempts = 0
|
||||||
@@ -61,20 +63,26 @@ class VideoPlayer:
|
|||||||
#self.message_handler.set_message('ERROR', 'load attempt fail')
|
#self.message_handler.set_message('ERROR', 'load attempt fail')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def pause_at_start(self):
|
def pause_at_start(self, show):
|
||||||
position = self.get_position()
|
position = self.get_position()
|
||||||
start_threshold = round(self.start - 0.05,2)
|
start_threshold = round(self.start - 0.05,2)
|
||||||
#print('is playing: {} , position : {} , start_threshold : {}'.format(self.omx_player.is_playing(), position, start_threshold))
|
#print('is playing: {} , position : {} , start_threshold : {}'.format(self.omx_player.is_playing(), position, start_threshold))
|
||||||
if position > start_threshold:
|
if position > start_threshold:
|
||||||
self.status = 'LOADED'
|
self.status = 'LOADED'
|
||||||
self.omx_player.set_alpha(255)
|
#if show:
|
||||||
|
# self.omx_player.set_alpha(255)
|
||||||
|
#else:
|
||||||
|
# self.omx_player.set_alpha(0)
|
||||||
self.omx_player.pause()
|
self.omx_player.pause()
|
||||||
elif self.omx_running:
|
elif self.omx_running:
|
||||||
self.root.after(5, self.pause_at_start)
|
self.root.after(5, self.pause_at_start, show)
|
||||||
|
|
||||||
def play(self):
|
def play(self, show):
|
||||||
self.status = 'PLAYING'
|
self.status = 'PLAYING'
|
||||||
#self.omx_player.set_alpha(255)
|
if show:
|
||||||
|
self.omx_player.set_alpha(255)
|
||||||
|
else:
|
||||||
|
self.omx_player.set_alpha(0)
|
||||||
self.omx_player.play()
|
self.omx_player.play()
|
||||||
self.pause_at_end()
|
self.pause_at_end()
|
||||||
|
|
||||||
@@ -91,7 +99,7 @@ class VideoPlayer:
|
|||||||
def reload(self):
|
def reload(self):
|
||||||
self.exit()
|
self.exit()
|
||||||
self.omx_running = False
|
self.omx_running = False
|
||||||
self.try_load()
|
self.try_load(True)
|
||||||
|
|
||||||
def is_loaded(self):
|
def is_loaded(self):
|
||||||
return self.status is 'LOADED'
|
return self.status is 'LOADED'
|
||||||
@@ -119,6 +127,14 @@ class VideoPlayer:
|
|||||||
self.omx_player.play_pause()
|
self.omx_player.play_pause()
|
||||||
self.status = self.omx_player.playback_status().upper()
|
self.status = self.omx_player.playback_status().upper()
|
||||||
|
|
||||||
|
def toggle_show(self):
|
||||||
|
if self.show_toggle_on:
|
||||||
|
self.show_toggle_on = False
|
||||||
|
self.omx_player.set_alpha(0)
|
||||||
|
else:
|
||||||
|
self.show_toggle_on = True
|
||||||
|
self.omx_player.set_alpha(255)
|
||||||
|
|
||||||
def seek(self, amount):
|
def seek(self, amount):
|
||||||
position = self.get_position()
|
position = self.get_position()
|
||||||
after_seek_position = position + amount
|
after_seek_position = position + amount
|
||||||
|
|||||||
Reference in New Issue
Block a user