mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-17 16:26:39 +03:00
f539147d48
This fixes all the license headers in the main library, which corrects the appearance of the main license in the compiled output. It seems that the `!` in the header forces the compiler to keep it in the output. I believe older compiler releases did this purely based on `@license`. Issue #2638 Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
/*! @license
|
|
* Shaka Player
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.provide('shaka.util.MediaReadyState');
|
|
|
|
goog.require('shaka.util.EventManager');
|
|
|
|
|
|
shaka.util.MediaReadyState = class {
|
|
/**
|
|
* @param {!HTMLMediaElement} mediaElement
|
|
* @param {number} readyState
|
|
* @param {shaka.util.EventManager} eventManager
|
|
* @param {function()} callback
|
|
*/
|
|
static waitForReadyState(mediaElement, readyState, eventManager, callback) {
|
|
if (readyState == HTMLMediaElement.HAVE_NOTHING ||
|
|
mediaElement.readyState >= readyState) {
|
|
callback();
|
|
} else {
|
|
const MediaReadyState = shaka.util.MediaReadyState;
|
|
const eventName =
|
|
MediaReadyState.READY_STATES_TO_EVENT_NAMES_.get(readyState);
|
|
eventManager.listenOnce(mediaElement, eventName, callback);
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @const {!Map.<number, string>}
|
|
* @private
|
|
*/
|
|
shaka.util.MediaReadyState.READY_STATES_TO_EVENT_NAMES_ = new Map([
|
|
[HTMLMediaElement.HAVE_METADATA, 'loadedmetadata'],
|
|
[HTMLMediaElement.HAVE_CURRENT_DATA, 'loadeddata'],
|
|
[HTMLMediaElement.HAVE_FUTURE_DATA, 'canplay'],
|
|
[HTMLMediaElement.HAVE_ENOUGH_DATA, 'canplaythrough'],
|
|
]);
|