Commit 6fa9a7f4 authored by David Trattnig's avatar David Trattnig
Browse files

Return to term "pre-load". #44

parent 8d9c9884
......@@ -238,13 +238,13 @@ class Player:
def preroll(self, entry):
def preload(self, entry):
"""
Pre-Rolls/Pre-Loads the entry. This is required before the actual `play(..)` can happen.
Pre-Load the entry. This is required before the actual `play(..)` can happen.
Be aware when using this method to queue a very short entry (shorter than ``) this may
result in sitations with incorrect timing. In this case bundle multiple short entries as
one queue using `preroll_playlist(self, entries)`.
one queue using `preload_playlist(self, entries)`.
It's important to note, that his method is blocking until loading has finished. If this
method is called asynchronously, the progress on the preloading state can be looked up in
......@@ -280,11 +280,11 @@ class Player:
def preroll_group(self, entries, channel_type=ChannelType.QUEUE):
def preload_group(self, entries, channel_type=ChannelType.QUEUE):
"""
Pre-Rolls/Pre-Loads multiple filesystem entries at once. This call is required before the
Pre-Load multiple filesystem entries at once. This call is required before the
actual `play(..)` can happen. Due to their nature, non-filesystem entries cannot be queued
using this method. In this case use `preroll(self, entry)` instead. This method also allows
using this method. In this case use `preload(self, entry)` instead. This method also allows
queuing of very short files, such as jingles.
It's important to note, that his method is blocking until loading has finished. If this
......@@ -325,7 +325,7 @@ class Player:
Plays a new `Entry`. In case of a new schedule (or some intented, immediate transition),
a clean channel is selected and transitions between old and new channel is performed.
This method expects that the entry is pre-loaded using `preroll(..)` or `preroll_group(self, entries)`
This method expects that the entry is pre-loaded using `preload(..)` or `preload_group(self, entries)`
before being played. In case the pre-roll has happened for a group of entries, only the
first entry of the group needs to be passed.
......@@ -422,7 +422,7 @@ class Player:
Args:
entries ([Entry]): The playlist entries
"""
self.preroll_group(entries, ChannelType.FALLBACK_QUEUE)
self.preload_group(entries, ChannelType.FALLBACK_QUEUE)
self.play(entries[0], TransitionType.FADE)
......
......@@ -56,7 +56,7 @@ class AuraScheduler(threading.Thread):
Aura Scheduler Class
- Retrieves data from Steering and Tank
- Stores and fires events for the sound-system
- Executes engine actions in an automated fashion
Attributes:
config (AuraConfig): Holds the Engine Configuration
......@@ -229,7 +229,7 @@ class AuraScheduler(threading.Thread):
self.logger.info("The FFWD [>>] range exceeds the length of the entry. Drink some tea and wait for the sound of the next entry.")
else:
# Pre-roll and play active entry
self.engine.player.preroll(active_entry)
self.engine.player.preload(active_entry)
self.engine.player.play(active_entry, TransitionType.FADE)
# Fast-forward to the scheduled position
......@@ -249,7 +249,7 @@ class AuraScheduler(threading.Thread):
or active_entry.get_content_type() in ResourceClass.LIVE.types:
# Pre-roll and play active entry
self.engine.player.preroll(active_entry)
self.engine.player.preload(active_entry)
self.engine.player.play(active_entry, TransitionType.FADE)
else:
......@@ -322,14 +322,14 @@ class AuraScheduler(threading.Thread):
def get_next_schedules(self, max_count=0):
def get_next_timeslots(self, max_count=0):
"""
Retrieves the schedules to be played after the current one.
Retrieves the timeslots to be played after the current one.
Args:
max_count (Integer): Maximum of schedules to return, if `0` all exitsing ones are returned
max_count (Integer): Maximum of timeslots to return, if `0` all exitsing ones are returned
Returns:
([Schedule]): The next schedules
([Timeslot]): The next timeslots
"""
now_unix = Engine.engine_time()
next_schedules = []
......@@ -446,7 +446,7 @@ class AuraScheduler(threading.Thread):
s += "\n SCHEDULED NEXT:"
s += "\n┌──────────────────────────────────────────────────────────────────────────────────────────────────────"
next_schedules = self.get_next_schedules()
next_schedules = self.get_next_timeslots()
if not next_schedules:
s += "\n│ Nothing. "
else:
......@@ -551,8 +551,8 @@ class AuraScheduler(threading.Thread):
timed commands to the sound-system to enable the individual tracks of playlists.
"""
# Get a clean set of the schedules within the scheduling window
schedules = self.get_next_schedules()
# Get a clean set of the timeslots within the scheduling window
schedules = self.get_next_timeslots()
schedules = self.filter_scheduling_window(schedules)
# Queue the schedules, their playlists and entries
......@@ -894,22 +894,22 @@ class AuraScheduler(threading.Thread):
if switcher:
# Pre-roll function to be called by timer
def do_preroll(entries):
def do_preload(entries):
try:
if entries[0].get_content_type() in ResourceClass.FILE.types:
self.logger.info(SU.cyan("=== preroll_group('%s') ===" % ResourceUtil.get_entries_string(entries)))
self.engine.player.preroll_group(entries, ChannelType.QUEUE)
self.logger.info(SU.cyan("=== preload_group('%s') ===" % ResourceUtil.get_entries_string(entries)))
self.engine.player.preload_group(entries, ChannelType.QUEUE)
else:
self.logger.info(SU.cyan("=== preroll('%s') ===" % ResourceUtil.get_entries_string(entries)))
self.engine.player.preroll(entries[0])
self.logger.info(SU.cyan("=== preload('%s') ===" % ResourceUtil.get_entries_string(entries)))
self.engine.player.preload(entries[0])
except LoadSourceException as e:
self.logger.critical(SU.red("Could not pre-roll entries %s" % ResourceUtil.get_entries_string(entries)), e)
if entries[-1].status != EntryPlayState.READY:
self.logger.critical(SU.red("Entries didn't reach 'ready' state during pre-rolling (Entries: %s)" % ResourceUtil.get_entries_string(entries)))
loader_diff = diff - self.config.get("preroll_offset")
loader = CallFunctionTimer(diff=loader_diff, func=do_preroll, param=param, fadein=fadein, fadeout=fadeout, switcher=False, loader=True)
loader_diff = diff - self.config.get("preload_offset")
loader = CallFunctionTimer(diff=loader_diff, func=do_preload, param=param, fadein=fadein, fadeout=fadeout, switcher=False, loader=True)
self.message_timer.append(loader)
loader.start()
return (t, loader)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment