mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-15 12:50:16 +01:00
player fades when alpha value changes
This commit is contained in:
18
actions.py
18
actions.py
@@ -74,7 +74,7 @@ class Actions(object):
|
|||||||
def load_slot_9_into_next_player(self):
|
def load_slot_9_into_next_player(self):
|
||||||
self._load_this_slot_into_next_player(9)
|
self._load_this_slot_into_next_player(9)
|
||||||
|
|
||||||
def trigger_next_player(self):
|
def switch_to_next_player(self):
|
||||||
self.video_driver.switch_players_and_play_video()
|
self.video_driver.switch_players_and_play_video()
|
||||||
|
|
||||||
def cycle_display_mode(self):
|
def cycle_display_mode(self):
|
||||||
@@ -91,10 +91,16 @@ class Actions(object):
|
|||||||
self.data.control_mode = 'PLAYER'
|
self.data.control_mode = 'PLAYER'
|
||||||
|
|
||||||
def toggle_pause_on_player(self):
|
def toggle_pause_on_player(self):
|
||||||
self.video_driver.current_player.toggle_pause()
|
if self.data.player_mode == 'now':
|
||||||
|
self.video_driver.current_player.toggle_pause()
|
||||||
|
elif self.data.player_mode == 'next':
|
||||||
|
self.video_driver.next_player.toggle_pause()
|
||||||
|
|
||||||
def toggle_show_on_player(self):
|
def toggle_show_on_player(self):
|
||||||
self.video_driver.current_player.toggle_show()
|
if self.data.player_mode == 'now':
|
||||||
|
self.video_driver.current_player.toggle_show()
|
||||||
|
elif self.data.player_mode == 'next':
|
||||||
|
self.video_driver.next_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)
|
||||||
@@ -171,6 +177,12 @@ class Actions(object):
|
|||||||
self.data.update_screen = True
|
self.data.update_screen = True
|
||||||
subprocess.call(['sudo', 'systemctl', 'stop', 'raspi2fb@1'])
|
subprocess.call(['sudo', 'systemctl', 'stop', 'raspi2fb@1'])
|
||||||
|
|
||||||
|
def toggle_player_mode(self):
|
||||||
|
if self.data.player_mode == 'now':
|
||||||
|
self.data.player_mode = 'next'
|
||||||
|
elif self.data.player_mode == 'next':
|
||||||
|
self.data.player_mode = 'now'
|
||||||
|
|
||||||
def set_the_camera_colour_u_with_cc(self, amount):
|
def set_the_camera_colour_u_with_cc(self, amount):
|
||||||
u_value = self._convert_midi_cc_value(amount, 0, 255)
|
u_value = self._convert_midi_cc_value(amount, 0, 255)
|
||||||
self.capture.set_colour(u_value, None)
|
self.capture.set_colour(u_value, None)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class Data(object):
|
|||||||
self.bank_number = 0
|
self.bank_number = 0
|
||||||
self.midi_status = 'disconnected'
|
self.midi_status = 'disconnected'
|
||||||
self.update_screen = True
|
self.update_screen = True
|
||||||
|
self.player_mode = 'now'
|
||||||
|
|
||||||
### persisted data:
|
### persisted data:
|
||||||
self.bank_data = self._read_json(self.BANK_DATA_JSON)
|
self.bank_data = self._read_json(self.BANK_DATA_JSON)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"location": "/media/pi/5EB5-664C/recur test videos/colour_pixal_01.mp4",
|
"location": "/media/pi/5EB5-664C/recur test videos/colour_pixal_01.mp4",
|
||||||
"name": "colour_pixal_01.mp4",
|
"name": "colour_pixal_01.mp4",
|
||||||
"rate": 1,
|
"rate": 1,
|
||||||
"start": 3.979
|
"start": -1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"end": -1,
|
"end": -1,
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
"location": "/media/pi/5EB5-664C/recur test videos/colour_pixal_02.mp4",
|
"location": "/media/pi/5EB5-664C/recur test videos/colour_pixal_02.mp4",
|
||||||
"name": "colour_pixal_02.mp4",
|
"name": "colour_pixal_02.mp4",
|
||||||
"rate": 1,
|
"rate": 1,
|
||||||
"start": 4.49
|
"start": -1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"end": -1,
|
"end": -1,
|
||||||
@@ -34,9 +34,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"end": -1,
|
"end": -1,
|
||||||
"length": -1,
|
"length": 804.245,
|
||||||
"location": "",
|
"location": "/media/pi/5EB5-664C/recur test videos/long_spinning.mp4",
|
||||||
"name": "",
|
"name": "long_spinning.mp4",
|
||||||
"rate": 1,
|
"rate": 1,
|
||||||
"start": -1
|
"start": -1
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
"NAV_SETTINGS": ["enter_on_settings_selection"]
|
"NAV_SETTINGS": ["enter_on_settings_selection"]
|
||||||
},
|
},
|
||||||
"d": {
|
"d": {
|
||||||
"DEFAULT": ["trigger_next_player"]
|
"DEFAULT": ["switch_to_next_player", "toggle_player_mode"]
|
||||||
},
|
},
|
||||||
"e": {
|
"e": {
|
||||||
"DEFAULT": ["set_playing_sample_start_to_current_duration", "clear_playing_sample_start_time"]
|
"DEFAULT": ["set_playing_sample_start_to_current_duration", "clear_playing_sample_start_time"]
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
"NAV_SETTINGS": ["enter_on_settings_selection"]
|
"NAV_SETTINGS": ["enter_on_settings_selection"]
|
||||||
},
|
},
|
||||||
"note_on 75": {
|
"note_on 75": {
|
||||||
"DEFAULT": ["trigger_next_player"]
|
"DEFAULT": ["switch_to_next_player"]
|
||||||
},
|
},
|
||||||
"note_on 76": {
|
"note_on 76": {
|
||||||
"DEFAULT": ["set_playing_sample_start_to_current_duration", "clear_playing_sample_start_time"]
|
"DEFAULT": ["set_playing_sample_start_to_current_duration", "clear_playing_sample_start_time"]
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
"on",
|
"on",
|
||||||
"off"
|
"off"
|
||||||
],
|
],
|
||||||
"value": "on"
|
"value": "off"
|
||||||
},
|
},
|
||||||
"QUIT": {
|
"QUIT": {
|
||||||
"action": "quit_the_program",
|
"action": "quit_the_program",
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
"on",
|
"on",
|
||||||
"off"
|
"off"
|
||||||
],
|
],
|
||||||
"value": "off"
|
"value": "on"
|
||||||
},
|
},
|
||||||
"LOAD_NEXT": {
|
"LOAD_NEXT": {
|
||||||
"action": "update_video_settings",
|
"action": "update_video_settings",
|
||||||
@@ -174,7 +174,7 @@
|
|||||||
"on",
|
"on",
|
||||||
"off"
|
"off"
|
||||||
],
|
],
|
||||||
"value": "off"
|
"value": "on"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"video": {
|
"video": {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ class Display(object):
|
|||||||
MENU_HEIGHT = 10
|
MENU_HEIGHT = 10
|
||||||
SELECTOR_WIDTH = 0.47
|
SELECTOR_WIDTH = 0.47
|
||||||
ROW_OFFSET = 6.0
|
ROW_OFFSET = 6.0
|
||||||
VIDEO_DISPLAY_BANNER_TEXT = ' {} {} {}'
|
|
||||||
|
|
||||||
def __init__(self, tk, video_driver, capture, message_handler, data):
|
def __init__(self, tk, video_driver, capture, message_handler, data):
|
||||||
self.tk = tk
|
self.tk = tk
|
||||||
@@ -35,9 +34,10 @@ class Display(object):
|
|||||||
self.display_text.tag_configure("DISPLAY_MODE", background="black", foreground="magenta")
|
self.display_text.tag_configure("DISPLAY_MODE", background="black", foreground="magenta")
|
||||||
self.display_text.tag_configure("ERROR_MESSAGE", background="red", foreground="white")
|
self.display_text.tag_configure("ERROR_MESSAGE", background="red", foreground="white")
|
||||||
self.display_text.tag_configure("INFO_MESSAGE", background="blue", foreground="white")
|
self.display_text.tag_configure("INFO_MESSAGE", background="blue", foreground="white")
|
||||||
self.display_text.tag_configure("PLAYER_INFO", background="black", foreground="yellow")
|
self.display_text.tag_configure("NOW_PLAYER_INFO", background="black", foreground="yellow")
|
||||||
self.display_text.tag_configure("COLUMN_NAME", background="black", foreground="cyan")
|
self.display_text.tag_configure("NEXT_PLAYER_INFO", background="black", foreground="cyan")
|
||||||
self.display_text.tag_configure("FUNCTION", background="cyan", foreground="black")
|
self.display_text.tag_configure("COLUMN_NAME", background="black", foreground="VioletRed1")
|
||||||
|
self.display_text.tag_configure("FUNCTION", background="yellow", foreground="black")
|
||||||
self.display_text.tag_configure("BROKEN_PATH", background="black", foreground="gray")
|
self.display_text.tag_configure("BROKEN_PATH", background="black", foreground="gray")
|
||||||
|
|
||||||
def _load_display(self):
|
def _load_display(self):
|
||||||
@@ -52,13 +52,20 @@ class Display(object):
|
|||||||
self.display_text.tag_add("TITLE", 1.19, 1.28)
|
self.display_text.tag_add("TITLE", 1.19, 1.28)
|
||||||
|
|
||||||
def _load_player(self):
|
def _load_player(self):
|
||||||
text, banner = self._get_info_for_player()
|
if self.data.player_mode == 'now':
|
||||||
end_of_text = float("3." + str(len(text)))
|
now_banner = self._get_banner_for_player('now')
|
||||||
end_of_banner = float("3." + str(len(banner)))
|
self.display_text.insert(END, now_banner + '\n')
|
||||||
self.display_text.insert(END, text + '\n')
|
self.display_text.tag_add("NOW_PLAYER_INFO", 2.0, 2.0 + self.SELECTOR_WIDTH)
|
||||||
self.display_text.tag_add("PLAYER_INFO", 2.0, end_of_text)
|
elif self.data.player_mode == 'next':
|
||||||
self.display_text.insert(END, banner + '\n')
|
next_banner = self._get_banner_for_player('next')
|
||||||
self.display_text.tag_add("PLAYER_INFO", 3.0, end_of_banner)
|
self.display_text.insert(END, next_banner + '\n')
|
||||||
|
self.display_text.tag_add("NEXT_PLAYER_INFO", 2.0, 2.0 + self.SELECTOR_WIDTH)
|
||||||
|
|
||||||
|
status = self._get_status_for_player()
|
||||||
|
self.display_text.insert(END, status + '\n')
|
||||||
|
self.display_text.tag_add("NOW_ALPHA", 3.0, 3.17)
|
||||||
|
self.display_text.tag_add("CAPTURE_ALPHA", 3.18, 3.29)
|
||||||
|
self.display_text.tag_add("NEXT_ALPHA", 3.29, 3.47)
|
||||||
|
|
||||||
def _load_display_body(self):
|
def _load_display_body(self):
|
||||||
if self.data.display_mode == 'BROWSER':
|
if self.data.display_mode == 'BROWSER':
|
||||||
@@ -156,19 +163,24 @@ class Display(object):
|
|||||||
self.display_text.tag_remove("SELECT", self.ROW_OFFSET + row,
|
self.display_text.tag_remove("SELECT", self.ROW_OFFSET + row,
|
||||||
self.ROW_OFFSET + self.SELECTOR_WIDTH + row)
|
self.ROW_OFFSET + self.SELECTOR_WIDTH + row)
|
||||||
|
|
||||||
def _get_info_for_player(self):
|
def _get_status_for_player(self):
|
||||||
now_slot, now_status, next_slot, next_status, position, crop_length, start, end = self.video_driver.get_info_for_player_display()
|
now_slot, now_status, now_alpha, next_slot, next_status, next_alpha = self.video_driver.get_player_info_for_status()
|
||||||
banner = self.create_video_display_banner(start, end, crop_length, position)
|
|
||||||
time_been = self.format_time_value(position - start)
|
|
||||||
time_left = self.format_time_value(end - position)
|
|
||||||
capture_status = self._generate_capture_status()
|
capture_status = self._generate_capture_status()
|
||||||
|
preview_alpha = self.capture.get_preview_alpha()
|
||||||
|
|
||||||
|
self._set_colour_from_alpha(now_alpha, preview_alpha, next_alpha)
|
||||||
|
|
||||||
now_info = 'NOW [{}] {}'.format(now_slot, now_status)
|
now_info = 'NOW [{}] {}'.format(now_slot, now_status)
|
||||||
next_info = 'NEXT [{}] {}'.format(next_slot, next_status)
|
next_info = 'NEXT [{}] {}'.format(next_slot, next_status)
|
||||||
capture_info = '{}'.format(capture_status)
|
capture_info = '{}'.format(capture_status)
|
||||||
|
return '{:17} {:10} {:17}'.format(now_info[:17], capture_info[:10], next_info[:18])
|
||||||
|
|
||||||
return self.VIDEO_DISPLAY_BANNER_TEXT.format(time_been, banner, time_left), \
|
def _get_banner_for_player(self,player):
|
||||||
'{:17} {:10} {:17}'.format(now_info[:17], capture_info[:10], next_info[:18])
|
start, end, position = self.video_driver.get_player_info_for_banner(player)
|
||||||
|
banner = self.create_video_display_banner(start, end, position)
|
||||||
|
time_been = self.format_time_value(position - start)
|
||||||
|
time_left = self.format_time_value(end - position)
|
||||||
|
return ' {:5} {} {:5}'.format(time_been, banner, time_left)
|
||||||
|
|
||||||
def _generate_capture_status(self):
|
def _generate_capture_status(self):
|
||||||
is_previewing = self.capture.is_previewing
|
is_previewing = self.capture.is_previewing
|
||||||
@@ -193,8 +205,7 @@ class Display(object):
|
|||||||
return capture_status
|
return capture_status
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_video_display_banner(start, end, crop_length, position):
|
def create_video_display_banner(start, end, position):
|
||||||
|
|
||||||
banner_list = ['[', '-', '-', '-', '-', '-', '-', '-', '-',
|
banner_list = ['[', '-', '-', '-', '-', '-', '-', '-', '-',
|
||||||
'-', '-', '-', '-', '-', '-', '-', '-', '-',
|
'-', '-', '-', '-', '-', '-', '-', '-', '-',
|
||||||
'-', '-', '-', '-', '-', '-', '-', '-', '-',
|
'-', '-', '-', '-', '-', '-', '-', '-', '-',
|
||||||
@@ -205,13 +216,34 @@ class Display(object):
|
|||||||
banner_list[0] = '<'
|
banner_list[0] = '<'
|
||||||
elif position > end:
|
elif position > end:
|
||||||
banner_list[max] = '>'
|
banner_list[max] = '>'
|
||||||
elif crop_length != 0:
|
elif end - start != 0:
|
||||||
marker = int(math.floor(float(position - start) /
|
marker = int(math.floor(float(position - start) /
|
||||||
float(crop_length) * (max - 1)) + 1)
|
float(end - start) * (max - 1)) + 1)
|
||||||
banner_list[marker] = '*'
|
banner_list[marker] = '*'
|
||||||
|
|
||||||
return ''.join(banner_list)
|
return ''.join(banner_list)
|
||||||
|
|
||||||
|
def _set_colour_from_alpha(self, now_alpha, preview_alpha, next_alpha):
|
||||||
|
upper_bound = 150
|
||||||
|
### scale values
|
||||||
|
scaled_now = int(( now_alpha / 255 ) * (255 - upper_bound) + upper_bound)
|
||||||
|
scaled_preview = int(( preview_alpha / 255 ) * (255 - upper_bound) + upper_bound)
|
||||||
|
scaled_next = int(( next_alpha / 255 ) * (255 - upper_bound) + upper_bound)
|
||||||
|
|
||||||
|
### convert to hex
|
||||||
|
now_colour = self.hex_from_rgb(scaled_now, scaled_now, 0)
|
||||||
|
capture_colour = self.hex_from_rgb(255 * self.capture.is_recording, 0, scaled_preview)
|
||||||
|
next_colour = self.hex_from_rgb(0, scaled_next, scaled_next)
|
||||||
|
### update the colours
|
||||||
|
self.display_text.tag_configure("NOW_ALPHA", background="black", foreground=now_colour)
|
||||||
|
self.display_text.tag_configure("CAPTURE_ALPHA", background="black", foreground=capture_colour)
|
||||||
|
self.display_text.tag_configure("NEXT_ALPHA", background="black", foreground=next_colour)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def hex_from_rgb(r, g, b):
|
||||||
|
return '#%02x%02x%02x' % (r, g, b)
|
||||||
|
|
||||||
|
|
||||||
def _update_screen_every_second(self):
|
def _update_screen_every_second(self):
|
||||||
self.refresh_display()
|
self.refresh_display()
|
||||||
self.tk.after(500, self._update_screen_every_second)
|
self.tk.after(500, self._update_screen_every_second)
|
||||||
@@ -224,36 +256,6 @@ class Display(object):
|
|||||||
self.display_text.configure(state='disable')
|
self.display_text.configure(state='disable')
|
||||||
self.display_text.focus_set()
|
self.display_text.focus_set()
|
||||||
|
|
||||||
def navigate_menu(self, move_direction, number_items_in_list):
|
|
||||||
last_list_index = number_items_in_list - 1
|
|
||||||
bottom_menu_index = self.top_menu_index + self.MENU_HEIGHT - 1
|
|
||||||
|
|
||||||
##self._unhighlight_this_row(self.selected_list_index - self.top_menu_index)
|
|
||||||
|
|
||||||
if move_direction == 'down':
|
|
||||||
if self.selected_list_index != last_list_index:
|
|
||||||
if self.selected_list_index == bottom_menu_index:
|
|
||||||
self.top_menu_index += 1
|
|
||||||
self.selected_list_index += 1
|
|
||||||
else:
|
|
||||||
self.top_menu_index = 0
|
|
||||||
self.selected_list_index = self.top_menu_index
|
|
||||||
|
|
||||||
elif move_direction == 'up':
|
|
||||||
if self.selected_list_index != 0:
|
|
||||||
if self.selected_list_index == self.top_menu_index:
|
|
||||||
self.top_menu_index -= 1
|
|
||||||
self.selected_list_index -= 1
|
|
||||||
else:
|
|
||||||
self.selected_list_index = last_list_index
|
|
||||||
self.top_menu_index = last_list_index - (self.MENU_HEIGHT - 1)
|
|
||||||
if self.top_menu_index < 0:
|
|
||||||
self.top_menu_index = 0
|
|
||||||
|
|
||||||
##self._highlight_this_row(self.selected_list_index - self.top_menu_index)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def format_time_value(time_in_seconds):
|
def format_time_value(time_in_seconds):
|
||||||
if time_in_seconds < 0:
|
if time_in_seconds < 0:
|
||||||
|
|||||||
@@ -157,17 +157,23 @@ class Capture(object):
|
|||||||
else:
|
else:
|
||||||
return self.device.frame.timestamp / 1000000
|
return self.device.frame.timestamp / 1000000
|
||||||
|
|
||||||
def is_previewing(self):
|
def get_preview_alpha(self):
|
||||||
if self.device.closed or not self.device.preview:
|
if self.is_previewing:
|
||||||
return False
|
return self.device.preview.alpha
|
||||||
else:
|
else:
|
||||||
return True
|
return 0
|
||||||
|
|
||||||
def is_recording(self):
|
#def is_previewing(self):
|
||||||
if self.device.recording:
|
# if self.device.closed or not self.device.preview:
|
||||||
return True
|
# return False
|
||||||
else:
|
#else:
|
||||||
return False
|
# return True
|
||||||
|
|
||||||
|
#def is_recording(self):
|
||||||
|
# if self.device.recording:
|
||||||
|
# return True
|
||||||
|
#else:
|
||||||
|
# return False
|
||||||
|
|
||||||
def set_colour(self, u_value, v_value):
|
def set_colour(self, u_value, v_value):
|
||||||
(u, v) = (128, 128)
|
(u, v) = (128, 128)
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class VideoDriver(object):
|
|||||||
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
|
|
||||||
if self.current_player.try_load(self.get_next_layer_value(), self.show_on_load):
|
if self.current_player.try_load(self.get_next_layer_value(), 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()
|
||||||
@@ -62,14 +61,15 @@ class VideoDriver(object):
|
|||||||
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()
|
self.switch_players()
|
||||||
|
|
||||||
def switch_players(self):
|
def switch_players(self):
|
||||||
temp_player = self.last_player
|
temp_player = self.last_player
|
||||||
self.last_player = self.current_player
|
self.last_player = self.current_player
|
||||||
self.current_player = self.next_player
|
self.current_player = self.next_player
|
||||||
self.next_player = temp_player
|
self.next_player = temp_player
|
||||||
#self.last_player.exit()
|
|
||||||
|
self.play_video()
|
||||||
|
|
||||||
def play_video(self):
|
def play_video(self):
|
||||||
print(self.play_on_start)
|
print(self.play_on_start)
|
||||||
@@ -95,17 +95,22 @@ class VideoDriver(object):
|
|||||||
if self.next_player.is_loaded():
|
if self.next_player.is_loaded():
|
||||||
self.in_next_load_cycle = False
|
self.in_next_load_cycle = False
|
||||||
self.switch_players()
|
self.switch_players()
|
||||||
self.play_video()
|
|
||||||
else:
|
else:
|
||||||
if self.next_player.status != 'ERROR':
|
if self.next_player.status != 'ERROR':
|
||||||
self.root.after(self.delay, self.switch_if_next_is_loaded)
|
self.root.after(self.delay, self.switch_if_next_is_loaded)
|
||||||
else:
|
else:
|
||||||
self.in_next_load_cycle = False
|
self.in_next_load_cycle = False
|
||||||
|
|
||||||
def get_info_for_player_display(self):
|
|
||||||
return self.current_player.bankslot_number, self.current_player.status, self.next_player.bankslot_number, \
|
def get_player_info_for_status(self):
|
||||||
self.next_player.status, self.current_player.get_position(), self.current_player.crop_length, \
|
return self.current_player.bankslot_number, self.current_player.status, self.current_player.alpha, \
|
||||||
self.current_player.start, self.current_player.end
|
self.next_player.bankslot_number, self.next_player.status, self.next_player.alpha
|
||||||
|
|
||||||
|
def get_player_info_for_banner(self, player):
|
||||||
|
if player == 'now':
|
||||||
|
return self.current_player.start, self.current_player.end, self.current_player.get_position()
|
||||||
|
elif player == 'next':
|
||||||
|
return self.next_player.start, self.next_player.end, self.next_player.get_position()
|
||||||
|
|
||||||
def exit_all_players(self):
|
def exit_all_players(self):
|
||||||
self.next_player.exit()
|
self.next_player.exit()
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class VideoPlayer:
|
|||||||
self.crop_length = 0.0
|
self.crop_length = 0.0
|
||||||
self.location = ''
|
self.location = ''
|
||||||
self.load_attempts = 0
|
self.load_attempts = 0
|
||||||
|
self.alpha = 0
|
||||||
|
|
||||||
self.show_toggle_on = True
|
self.show_toggle_on = True
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ class VideoPlayer:
|
|||||||
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()
|
||||||
arguments = ['--no-osd', '--layer', str(layer), '--adev', 'local', '--alpha', '0', first_screen_arg, second_screen_arg]
|
arguments = ['--no-osd', '--layer', str(layer), '--adev', 'local', '--alpha', '0', first_screen_arg, second_screen_arg]
|
||||||
if not is_dev_mode:
|
if not is_dev_mode:
|
||||||
arguments.append('-b')
|
arguments.append('-b') ##=0x000000FF')
|
||||||
self.status = 'LOADING'
|
self.status = 'LOADING'
|
||||||
print('the location is {}'.format(self.location))
|
print('the location is {}'.format(self.location))
|
||||||
self.omx_player = OMXPlayer(self.location, args=arguments, dbus_name=self.name)
|
self.omx_player = OMXPlayer(self.location, args=arguments, dbus_name=self.name)
|
||||||
@@ -71,9 +72,9 @@ class VideoPlayer:
|
|||||||
if position > start_threshold:
|
if position > start_threshold:
|
||||||
self.status = 'LOADED'
|
self.status = 'LOADED'
|
||||||
if show:
|
if show:
|
||||||
self.omx_player.set_alpha(255)
|
self.set_alpha_value(255)
|
||||||
else:
|
else:
|
||||||
self.omx_player.set_alpha(0)
|
self.set_alpha_value(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, show)
|
self.root.after(5, self.pause_at_start, show)
|
||||||
@@ -81,9 +82,9 @@ class VideoPlayer:
|
|||||||
def play(self, show):
|
def play(self, show):
|
||||||
self.status = 'PLAYING'
|
self.status = 'PLAYING'
|
||||||
if show:
|
if show:
|
||||||
self.omx_player.set_alpha(255)
|
self.set_alpha_value(255)
|
||||||
else:
|
else:
|
||||||
self.omx_player.set_alpha(0)
|
self.set_alpha_value(0)
|
||||||
self.omx_player.play()
|
self.omx_player.play()
|
||||||
self.pause_at_end()
|
self.pause_at_end()
|
||||||
|
|
||||||
@@ -131,10 +132,14 @@ class VideoPlayer:
|
|||||||
def toggle_show(self):
|
def toggle_show(self):
|
||||||
if self.show_toggle_on:
|
if self.show_toggle_on:
|
||||||
self.show_toggle_on = False
|
self.show_toggle_on = False
|
||||||
self.omx_player.set_alpha(0)
|
self.set_alpha_value(0)
|
||||||
else:
|
else:
|
||||||
self.show_toggle_on = True
|
self.show_toggle_on = True
|
||||||
self.omx_player.set_alpha(255)
|
self.set_alpha_value(255)
|
||||||
|
|
||||||
|
def set_alpha_value(self, amount):
|
||||||
|
self.omx_player.set_alpha(amount)
|
||||||
|
self.alpha = amount
|
||||||
|
|
||||||
def seek(self, amount):
|
def seek(self, amount):
|
||||||
position = self.get_position()
|
position = self.get_position()
|
||||||
|
|||||||
Reference in New Issue
Block a user