mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-13 11:50:12 +01:00
using different layers for each video so now and next can be mixed
This commit is contained in:
@@ -42,7 +42,7 @@ class Actions(object):
|
|||||||
|
|
||||||
def _load_this_slot_into_next_player(self, slot):
|
def _load_this_slot_into_next_player(self, slot):
|
||||||
self.data.update_next_slot_number(slot)
|
self.data.update_next_slot_number(slot)
|
||||||
self.video_driver.next_player.reload()
|
self.video_driver.reload_next_player()
|
||||||
|
|
||||||
def load_slot_0_into_next_player(self):
|
def load_slot_0_into_next_player(self):
|
||||||
self._load_this_slot_into_next_player(0)
|
self._load_this_slot_into_next_player(0)
|
||||||
|
|||||||
@@ -95,25 +95,11 @@ class Data(object):
|
|||||||
self.next_bankslot = '{}-{}'.format(self.bank_number,new_value)
|
self.next_bankslot = '{}-{}'.format(self.bank_number,new_value)
|
||||||
self._update_json(self.NEXT_BANKSLOT_JSON,self.next_bankslot)
|
self._update_json(self.NEXT_BANKSLOT_JSON,self.next_bankslot)
|
||||||
|
|
||||||
def check_if_setting_selection_is_action_otherwise_cycle_value(self, setting_index):
|
|
||||||
######## update the value of selected setting by cycling through valid options ########
|
|
||||||
if(self.setting['options'][0] == 'run_action'):
|
|
||||||
return True, self.setting['name']
|
|
||||||
else:
|
|
||||||
self.cycle_setting_value(setting_index)
|
|
||||||
return False, None
|
|
||||||
|
|
||||||
def update_setting_value(self, setting_folder, setting_name, setting_value):
|
def update_setting_value(self, setting_folder, setting_name, setting_value):
|
||||||
self.settings[setting_folder][setting_name]['value'] = setting_value
|
self.settings[setting_folder][setting_name]['value'] = setting_value
|
||||||
self._update_json(self.SETTINGS_JSON, self.settings)
|
self._update_json(self.SETTINGS_JSON, self.settings)
|
||||||
return self.settings[setting_folder][setting_name]
|
return self.settings[setting_folder][setting_name]
|
||||||
|
|
||||||
def cycle_setting_value(self, setting_index):
|
|
||||||
this_setting_option = self.settings[setting_index]['options']
|
|
||||||
this_setting_option= this_setting_option[len(this_setting_option)-1:]+this_setting_option[0:len(this_setting_option)-1]
|
|
||||||
self.settings[setting_index]['options'] = this_setting_option
|
|
||||||
self._update_json(self.SETTINGS_JSON, self.settings)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def split_bankslot_number(cls, bankslot_number):
|
def split_bankslot_number(cls, bankslot_number):
|
||||||
split = bankslot_number.split('-')
|
split = bankslot_number.split('-')
|
||||||
|
|||||||
@@ -2,25 +2,25 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"end": -1,
|
"end": -1,
|
||||||
"length": 1132.04,
|
"length": 804.245,
|
||||||
"location": "/media/pi/5EB5-664C/recur test videos/mushroom-dreams.mp4",
|
"location": "/media/pi/5EB5-664C/recur test videos/long_spinning.mp4",
|
||||||
"name": "mushroom-dreams.mp4",
|
"name": "long_spinning.mp4",
|
||||||
"rate": 1,
|
"rate": 1,
|
||||||
"start": -1
|
"start": -1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"end": -1,
|
"end": -1,
|
||||||
"length": 6.96,
|
"length": 40.533,
|
||||||
"location": "/home/pi/Videos/recordings/rec-2018-04-25-1.mp4",
|
"location": "/media/pi/5EB5-664C/recur test videos/colour_pixal_04.mp4",
|
||||||
"name": "rec-2018-04-25-1.mp4",
|
"name": "colour_pixal_04.mp4",
|
||||||
"rate": 1,
|
"rate": 1,
|
||||||
"start": -1
|
"start": -1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"end": -1,
|
"end": -1,
|
||||||
"length": 4.714,
|
"length": -1,
|
||||||
"location": "/media/pi/5EB5-664C/recur test videos/samplerloop3s2.mp4",
|
"location": "",
|
||||||
"name": "samplerloop3s2.mp4",
|
"name": "",
|
||||||
"rate": 1,
|
"rate": 1,
|
||||||
"start": -1
|
"start": -1
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
from video_centre.video_player import VideoPlayer
|
from video_centre.video_player import VideoPlayer
|
||||||
|
|
||||||
class VideoDriver(object):
|
class VideoDriver(object):
|
||||||
|
|
||||||
|
MAX_LAYER = 1000000000
|
||||||
|
|
||||||
def __init__(self, root, message_handler, data):
|
def __init__(self, root, message_handler, data):
|
||||||
self.root = root
|
self.root = root
|
||||||
self.message_handler = message_handler
|
self.message_handler = message_handler
|
||||||
@@ -10,16 +13,15 @@ class VideoDriver(object):
|
|||||||
self.in_current_playing_cycle = False
|
self.in_current_playing_cycle = False
|
||||||
self.in_next_load_cycle = False
|
self.in_next_load_cycle = False
|
||||||
|
|
||||||
|
self.layer = self.MAX_LAYER
|
||||||
|
|
||||||
self.last_player = VideoPlayer(self.root, self.message_handler, self.data, 'a.a')
|
self.last_player = VideoPlayer(self.root, self.message_handler, self.data, 'a.a')
|
||||||
self.current_player = VideoPlayer(self.root,self.message_handler, self.data, 'b.b')
|
self.current_player = VideoPlayer(self.root,self.message_handler, self.data, 'b.b')
|
||||||
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.update_video_settings()
|
||||||
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):
|
def update_video_settings(self):
|
||||||
self.switch_on_finish = self.data.settings['sampler']['ON_FINISH']['value'] == 'switch'
|
self.switch_on_finish = self.data.settings['sampler']['ON_FINISH']['value'] == 'switch'
|
||||||
@@ -27,6 +29,12 @@ class VideoDriver(object):
|
|||||||
self.show_on_start = 'show' 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']
|
self.show_on_load = 'show' == self.data.settings['sampler']['ON_LOAD']['value']
|
||||||
|
|
||||||
|
def get_next_layer_value(self):
|
||||||
|
if self.layer > 0:
|
||||||
|
self.layer = self.layer - 1
|
||||||
|
else:
|
||||||
|
self.layer = self.MAX_LAYER
|
||||||
|
return self.layer
|
||||||
|
|
||||||
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,))
|
||||||
@@ -34,7 +42,7 @@ class VideoDriver(object):
|
|||||||
|
|
||||||
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(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()
|
||||||
else:
|
else:
|
||||||
@@ -67,7 +75,7 @@ class VideoDriver(object):
|
|||||||
if self.play_on_start:
|
if self.play_on_start:
|
||||||
self.current_player.play(self.show_on_start)
|
self.current_player.play(self.show_on_start)
|
||||||
self.last_player.exit()
|
self.last_player.exit()
|
||||||
self.next_player.try_load(self.show_on_load)
|
self.next_player.try_load(self.get_next_layer_value() ,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()
|
||||||
|
|
||||||
@@ -103,5 +111,5 @@ class VideoDriver(object):
|
|||||||
self.current_player.exit()
|
self.current_player.exit()
|
||||||
|
|
||||||
def reload_next_player(self):
|
def reload_next_player(self):
|
||||||
self.next_player.reload(self,show_on_load)
|
self.next_player.reload(self.get_next_layer_value(), self.show_on_load)
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ class VideoPlayer:
|
|||||||
|
|
||||||
self.show_toggle_on = True
|
self.show_toggle_on = True
|
||||||
|
|
||||||
def try_load(self, show):
|
def try_load(self, layer ,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(show):
|
if self.load(layer, show):
|
||||||
print('load success')
|
print('load success')
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@@ -34,16 +34,16 @@ class VideoPlayer:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def load(self, show):
|
def load(self, layer , 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()
|
||||||
self.arguments = ['--no-osd', '--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:
|
||||||
self.arguments.append('-b')
|
arguments.append('-b')
|
||||||
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=self.arguments, dbus_name=self.name)
|
self.omx_player = OMXPlayer(self.location, args=arguments, dbus_name=self.name)
|
||||||
self.omx_running = True
|
self.omx_running = True
|
||||||
self.total_length = self.omx_player.duration() # <-- uneeded once self.duration stores float
|
self.total_length = self.omx_player.duration() # <-- uneeded once self.duration stores float
|
||||||
if(self.end is -1):
|
if(self.end is -1):
|
||||||
@@ -69,11 +69,11 @@ class VideoPlayer:
|
|||||||
#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'
|
||||||
#if show:
|
if show:
|
||||||
# self.omx_player.set_alpha(255)
|
self.omx_player.set_alpha(255)
|
||||||
#else:
|
else:
|
||||||
# self.omx_player.set_alpha(0)
|
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, show)
|
self.root.after(5, self.pause_at_start, show)
|
||||||
|
|
||||||
@@ -96,10 +96,10 @@ class VideoPlayer:
|
|||||||
elif(self.omx_running):
|
elif(self.omx_running):
|
||||||
self.root.after(5, self.pause_at_end)
|
self.root.after(5, self.pause_at_end)
|
||||||
|
|
||||||
def reload(self):
|
def reload(self, layer, show):
|
||||||
self.exit()
|
self.exit()
|
||||||
self.omx_running = False
|
self.omx_running = False
|
||||||
self.try_load(True)
|
self.try_load(layer, show)
|
||||||
|
|
||||||
def is_loaded(self):
|
def is_loaded(self):
|
||||||
return self.status is 'LOADED'
|
return self.status is 'LOADED'
|
||||||
|
|||||||
Reference in New Issue
Block a user