mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-12 19:30:11 +01:00
update video_player to take start and end values
This commit is contained in:
@@ -66,7 +66,7 @@ def get_path_to_browser():
|
|||||||
logger = setup_logging()
|
logger = setup_logging()
|
||||||
|
|
||||||
######## sets paths and constants ########
|
######## sets paths and constants ########
|
||||||
PATH_TO_DATA_OBJECTS = '{}\\data_objects\\'.format(get_the_current_dir_path())
|
PATH_TO_DATA_OBJECTS = '{}data_objects/'.format(get_the_current_dir_path())
|
||||||
PATH_TO_BROWSER = get_path_to_browser()
|
PATH_TO_BROWSER = get_path_to_browser()
|
||||||
EMPTY_BANK = dict(name='',location='',length=-1,start=-1,end=-1)
|
EMPTY_BANK = dict(name='',location='',length=-1,start=-1,end=-1)
|
||||||
DEV_MODE = read_json(SETTINGS_JSON)[6]["value"]
|
DEV_MODE = read_json(SETTINGS_JSON)[6]["value"]
|
||||||
|
|||||||
@@ -49,9 +49,9 @@
|
|||||||
"location": "/media/pi/TIM1/TRASHPALACEVIDEOS/01_trashpalaceintro.mp4"
|
"location": "/media/pi/TIM1/TRASHPALACEVIDEOS/01_trashpalaceintro.mp4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"start": -1,
|
"start": 10,
|
||||||
"length": 49,
|
"length": 49,
|
||||||
"end": -1,
|
"end": 15,
|
||||||
"name": "colour_pixel_01.mp4",
|
"name": "colour_pixel_01.mp4",
|
||||||
"location": "/media/pi/TIM1/videos_to_play/colour_pixel_01.mp4"
|
"location": "/media/pi/TIM1/videos_to_play/colour_pixel_01.mp4"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
6
|
7
|
||||||
@@ -1 +1 @@
|
|||||||
[{"name": "PLAYBACK_MODE", "value": "PLAYLIST"}, {"name": "PLAYLIST", "value": "[1,1,1,4,1,2,1,4]"}, {"name": "SYNC_LENGTHS", "value": "ON"}, {"name": "SYNC_LENGTHS_TO", "value": "00:08"}, {"name": "RAND_START", "value": "OFF"}, {"name": "VIDEO_OUTPUT", "value": "COMPOSITE"}, {"name": "DEV_MODE", "value": "ON"}]
|
[{"name": "PLAYBACK_MODE", "value": "LOOPER"}, {"name": "PLAYLIST", "value": "[1,1,1,4,1,2,1,4]"}, {"name": "SYNC_LENGTHS", "value": "OFF"}, {"name": "SYNC_LENGTHS_TO", "value": "00:08"}, {"name": "RAND_START", "value": "OFF"}, {"name": "VIDEO_OUTPUT", "value": "COMPOSITE"}, {"name": "DEV_MODE", "value": "ON"}]
|
||||||
|
|||||||
@@ -30,26 +30,35 @@ class video_player:
|
|||||||
self.player = OMXPlayer(self.location, args=self.arguments, dbus_name=self.name)
|
self.player = OMXPlayer(self.location, args=self.arguments, dbus_name=self.name)
|
||||||
self.omx_running = True
|
self.omx_running = True
|
||||||
self.duration = self.player.duration()
|
self.duration = self.player.duration()
|
||||||
|
if(self.end is -1):
|
||||||
|
self.end = self.duration
|
||||||
|
if(self.start is -1):
|
||||||
|
self.start = 0
|
||||||
print('{}: the duration is {}'.format(self.name, self.duration))
|
print('{}: the duration is {}'.format(self.name, self.duration))
|
||||||
|
if(self.start > 0.5):
|
||||||
|
self.set_position(self.start - 0.5)
|
||||||
self.pause_at_start()
|
self.pause_at_start()
|
||||||
|
|
||||||
def pause_at_start(self):
|
def pause_at_start(self):
|
||||||
position = self.get_position()
|
position = self.get_position()
|
||||||
if(position > -0.05):
|
start_threshold = self.start - 0.05
|
||||||
|
print('position:{} threshold:{}'.format(position, start_threshold))
|
||||||
|
if(position > start_threshold):
|
||||||
self.status = 'LOADED'
|
self.status = 'LOADED'
|
||||||
self.player.pause()
|
self.player.pause()
|
||||||
|
self.player.set_alpha(255)
|
||||||
elif(self.omx_running):
|
elif(self.omx_running):
|
||||||
self.root.after(5,self.pause_at_start)
|
self.root.after(5,self.pause_at_start)
|
||||||
|
|
||||||
def play(self):
|
def play(self):
|
||||||
self.status = 'PLAYING'
|
self.status = 'PLAYING'
|
||||||
self.player.set_alpha(255)
|
|
||||||
self.player.play()
|
self.player.play()
|
||||||
self.pause_at_end()
|
self.pause_at_end()
|
||||||
|
|
||||||
def pause_at_end(self):
|
def pause_at_end(self):
|
||||||
position = self.get_position()
|
position = self.get_position()
|
||||||
if(position > (self.duration - 0.2 )):
|
end_threshold = self.end - 0.2
|
||||||
|
if(position > end_threshold):
|
||||||
self.status = 'FINISHED'
|
self.status = 'FINISHED'
|
||||||
self.player.pause()
|
self.player.pause()
|
||||||
print('its paused at end!')
|
print('its paused at end!')
|
||||||
@@ -89,6 +98,9 @@ class video_player:
|
|||||||
def seek(self, amount):
|
def seek(self, amount):
|
||||||
self.player.seek(amount)
|
self.player.seek(amount)
|
||||||
|
|
||||||
|
def set_position(self, position):
|
||||||
|
self.player.set_position(position)
|
||||||
|
|
||||||
def exit(self):
|
def exit(self):
|
||||||
try:
|
try:
|
||||||
self.player.quit()
|
self.player.quit()
|
||||||
|
|||||||
Reference in New Issue
Block a user