The media handler to act upon. The playback rate controller must already be available.
Private _isWhether media playback is paused
Private _loopThe loop end
Private _loopThe loop mode (recurring by default)
Private _loopThe loop start
Private _mediaThe media handler to act upon
Private isWhether the loop end is currently handeled (by possibly fading and then by seeking back to the start).
This is (an internal) flag to prevent re-triggering of fade-outs and seeks when loop end handling is already in progress
Private loopA measured duration for the seek operation when executing a loop in [seconds]. This is used to compensate the seek target with, to have the loop start accounted for this duration
This value is measured at each executed loop. The initially set value is a reasonable default.
Private nonThe range for which a too short loop timer is not rescheduled.
Experience has shown, that small rescheduling near the end of the actual loop end worsen the loop timing. These are prevented within this margin.
Private schedulingA handle to the scheduler for lopp handling
Private trackA safety margin for detecting the end of a track during playback while looping
This value was empirically determined. It's dependent of CPU power and timing accurracy
Whether to use fading on loop boundaries
Off by default to provide continuous playback when looping back to the start.
Gets the end time of the loop range.
Gets the start time of the loop range.
Sets a ranged loop
Private cancelExecutes a due loop for the given timings
The start of the loop in [seconds]
The end of the loop in [seconds]
how to handle the possible loop
Determines whether a loop is deemed required due to the timings and returns a boolean accordingly
Private isPrivate schedule
Implements range looping for an {IMediaHandler}, including fading.
Remarks
Implements optional audio fading at the loop boundaries, with the help of an {IAudioFader}.
Devdoc
This IMediaHandler based approach (with observing of the current time on the wrapped media element) is used to emulate the buffer looping for the enclosed media element. Replayer does intentionally not use buffered audio sources, to be able to play online media without CORS headers. See https://www.w3.org/TR/webaudio/#looping-AudioBufferSourceNode for information about looping.