/** * Copyright 2015 CANAL+ Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import type { IManifestMetadata } from "../../../../manifest"; import type { IPlaybackObservation, IReadOnlyPlaybackObserver } from "../../../../playback_observer"; import EventEmitter from "../../../../utils/event_emitter"; import type { IPublicNonFiniteStreamEvent, IPublicStreamEvent } from "./types"; interface IStreamEventsEmitterEvent { event: IPublicStreamEvent | IPublicNonFiniteStreamEvent; eventSkip: IPublicStreamEvent | IPublicNonFiniteStreamEvent; } /** * Get events from manifest and emit each time an event has to be emitted */ export default class StreamEventsEmitter extends EventEmitter { /** Regularly emit playback metrics such as the position. */ private _playbackObserver; /** Current stream events tracked for the whole content. */ private _scheduledEventsRef; /** Events currently considered active, to only emit their enter/exit once. */ private _eventsBeingPlayed; /** Whether event evaluation is temporarily suspended, e.g. during a reload. */ private _isPaused; /** Last observation used as comparison point for the next event check. */ private _previousObservation; /** Cancels the current emitter lifecycle. */ private _canceller; /** * @param {Object} playbackObserver */ constructor(playbackObserver: IReadOnlyPlaybackObserver); /** * Initialize the emitter for the given content manifest. * * The emitter starts in a paused state so the caller can resume it only once * the corresponding media instance is actually ready. * @param {Object} manifest */ start(manifest: IManifestMetadata): void; /** * Suspend event evaluation until `resume` has been called. * * To use when playback metrics should be temporarily ignored, for example * while reloading a content. */ pause(): void; /** * Resume event evaluation from the current playback state. */ resume(): void; /** Refresh the tracked stream-event list after a manifest update. */ onManifestUpdate(man: IManifestMetadata): void; /** * @param {string | undefined} reason - Human-inspectable reason behind the * stop. Used for debugging matters, especially for debug log * inspection. */ stop(reason: string | undefined): void; /** * Construct observation object relied on by the `StreamEventsEmitted` by * generating it from this instance's `PlaybackObserver`. */ private _constructObservation; /** * Examine playback situation from playback observations to emit stream events and * prepare `onExit` callbacks if needed. * @param {Array.} scheduledEvents * @param {Object} oldObservation * @param {Object} newObservation * @param {Object} stopSignal */ private _emitStreamEvents; } export {}; //# sourceMappingURL=stream_events_emitter.d.ts.map