UNPKG

shaka-player

Version:
1,555 lines (1,552 loc) 96.2 kB
/** * @fileoverview Generated externs. DO NOT EDIT! * @externs * @suppress {duplicate} To prevent compiler errors with the namespace * being declared both here and by goog.provide in the library. */ /** @namespace */ window.shaka = {}; /** @const */ shaka.abr = {}; /** @const */ shaka.cast = {}; /** @const */ shaka.dash = {}; /** @const */ shaka.hls = {}; /** @const */ shaka.media = {}; /** @const */ shaka.media.ManifestParser = {}; /** @const */ shaka.net = {}; /** @const */ shaka.offline = {}; /** @const */ shaka.polyfill = {}; /** @const */ shaka.text = {}; /** @const */ shaka.text.TextEngine = {}; /** @const */ shaka.text.TextEngine.prototype = {}; /** @const */ shaka.util = {}; /** @const */ shaka.util.ConfigUtils = {}; /** @const */ shaka.util.StringUtils = {}; /** @const */ shaka.util.Uint8ArrayUtils = {}; /** @const */ shaka.ui = {}; /** @const */ shaka.ui.Utils = {}; /** * A work-alike for EventTarget. Only DOM elements may be true EventTargets, * but this can be used as a base class to provide event dispatch to non-DOM * classes. Only FakeEvents should be dispatched. * @struct * @constructor * @implements {EventTarget} */ shaka.util.FakeEventTarget = function() {}; /** * These are the listener types defined in the closure extern for EventTarget. * @typedef {EventListener|function(!Event):*} */ shaka.util.FakeEventTarget.ListenerType; /** * Add an event listener to this object. * @param {string} type The event type to listen for. * @param {shaka.util.FakeEventTarget.ListenerType} listener The callback or * listener object to invoke. * @param {(!AddEventListenerOptions|boolean)=} options Ignored. * @override */ shaka.util.FakeEventTarget.prototype.addEventListener = function(type, listener, options) {}; /** * Remove an event listener from this object. * @param {string} type The event type for which you wish to remove a listener. * @param {shaka.util.FakeEventTarget.ListenerType} listener The callback or * listener object to remove. * @param {(EventListenerOptions|boolean)=} options Ignored. * @override */ shaka.util.FakeEventTarget.prototype.removeEventListener = function(type, listener, options) {}; /** * Dispatch an event from this object. * @param {!Event} event The event to be dispatched from this object. * @return {boolean} True if the default action was prevented. * @override */ shaka.util.FakeEventTarget.prototype.dispatchEvent = function(event) {}; /** * Localization system provided by the shaka ui library. * It can be used to store the various localized forms of * strings that are expected to be displayed to the user. * If a string is not available, it will return the localized * form in the closest related locale. * @implements {EventTarget} * @final */ shaka.ui.Localization = class { /** * @param {string} fallbackLocale * The fallback locale that should be used. It will be assumed that this * locale should have entries for just about every request. */ constructor(fallbackLocale) {} /** * @override */ addEventListener(type,listener,options) {} /** * @override */ removeEventListener(type,listener,options) {} /** * @override */ dispatchEvent(event) {} /** * Request the localization system to change which locale it serves. If any of * of the preferred locales cannot be found, the localization system will fire * an event identifying which locales it does not know. The localization * system will then continue to operate using the closest matches it has. * @param {!Iterable.<string>} locales * The locale codes for the requested locales in order of preference. */ changeLocale(locales) {} /** * Insert a set of localizations for a single locale. This will amend the * existing localizations for the given locale. * @param {string} locale * The locale that the localizations should be added to. * @param {!Map.<string, string>} localizations * A mapping of id to localized text that should used to modify the internal * collection of localizations. * @param {shaka.ui.Localization.ConflictResolution=} conflictResolution * The strategy used to resolve conflicts when the id of an existing entry * matches the id of a new entry. Default to |USE_NEW|, where the new * entry will replace the old entry. * @return {!shaka.ui.Localization} * Returns |this| so that calls can be chained. */ insert(locale,localizations,conflictResolution) {} /** * Set the value under each key in |dictionary| to the resolved value. * Convenient for apps with some kind of data binding system. * Equivalent to: * for (const key of dictionary.keys()) { * dictionary.set(key, localization.resolve(key)); * } * @param {!Map.<string, string>} dictionary */ resolveDictionary(dictionary) {} /** * Request the localized string under the given id. If there is no localized * version of the string, then the fallback localization will be given * ("en" version). If there is no fallback localization, a non-null empty * string will be returned. * @param {string} id The id for the localization entry. * @return {string} */ resolve(id) {} }; /** * An enum for how the localization system should resolve conflicts between old * translations and new translations. * @enum {number} */ shaka.ui.Localization.ConflictResolution = { 'USE_OLD': 0, 'USE_NEW': 1 }; /** * The event name for when locales were requested, but we could not find any * entries for them. The localization system will continue to use the closest * matches it has. * @const {string} */ shaka.ui.Localization.UNKNOWN_LOCALES; /** * The event name for when an entry could not be found in the preferred locale, * related locales, or the fallback locale. * @const {string} */ shaka.ui.Localization.UNKNOWN_LOCALIZATION; /** * The event name for when entries are missing from the user's preferred * locale, but we were able to find an entry in a related locale or the fallback * locale. * @const {string} */ shaka.ui.Localization.MISSING_LOCALIZATIONS; /** * The event name for when a new locale has been requested and any previously * resolved values should be updated. * @const {string} */ shaka.ui.Localization.LOCALE_CHANGED; /** * The event name for when |insert| was called and it changed entries that could * affect previously resolved values. * @const {string} */ shaka.ui.Localization.LOCALE_UPDATED; /** * A timer allows a single function to be executed at a later time or at * regular intervals. * @final */ shaka.util.Timer = class { /** * Create a new timer. A timer is committed to a single callback function. * While there is no technical reason to do this, it is far easier to * understand and use timers when they are connected to one functional idea. * @param {function()} onTick */ constructor(onTick) {} /** * Have the timer call |onTick| now. * @return {!shaka.util.Timer} */ tickNow() {} /** * Have the timer call |onTick| after |seconds| has elapsed unless |stop| is * called first. * @param {number} seconds * @return {!shaka.util.Timer} */ tickAfter(seconds) {} /** * Have the timer call |onTick| every |seconds| until |stop| is called. * @param {number} seconds * @return {!shaka.util.Timer} */ tickEvery(seconds) {} /** * Stop the timer and clear the previous behaviour. The timer is still usable * after calling |stop|. */ stop() {} }; /** * Creates a new Error. * @param {shaka.util.Error.Severity} severity * @param {shaka.util.Error.Category} category * @param {shaka.util.Error.Code} code * @param {...*} varArgs * @constructor * @struct * @extends {Error} * @implements {shaka.extern.Error} */ shaka.util.Error = function(severity, category, code, ...varArgs) {}; /** * @override */ shaka.util.Error.prototype.severity; /** * @override */ shaka.util.Error.prototype.category; /** * @override */ shaka.util.Error.prototype.code; /** * @override */ shaka.util.Error.prototype.data; /** * @override */ shaka.util.Error.prototype.handled; /** * @enum {number} */ shaka.util.Error.Severity = { 'RECOVERABLE': 1, 'CRITICAL': 2 }; /** * @enum {number} */ shaka.util.Error.Category = { 'NETWORK': 1, 'TEXT': 2, 'MEDIA': 3, 'MANIFEST': 4, 'STREAMING': 5, 'DRM': 6, 'PLAYER': 7, 'CAST': 8, 'STORAGE': 9 }; /** * @enum {number} */ shaka.util.Error.Code = { 'UNSUPPORTED_SCHEME': 1000, 'BAD_HTTP_STATUS': 1001, 'HTTP_ERROR': 1002, 'TIMEOUT': 1003, 'MALFORMED_DATA_URI': 1004, 'UNKNOWN_DATA_URI_ENCODING': 1005, 'REQUEST_FILTER_ERROR': 1006, 'RESPONSE_FILTER_ERROR': 1007, 'MALFORMED_TEST_URI': 1008, 'UNEXPECTED_TEST_REQUEST': 1009, 'INVALID_TEXT_HEADER': 2000, 'INVALID_TEXT_CUE': 2001, 'UNABLE_TO_DETECT_ENCODING': 2003, 'BAD_ENCODING': 2004, 'INVALID_XML': 2005, 'INVALID_MP4_TTML': 2007, 'INVALID_MP4_VTT': 2008, 'UNABLE_TO_EXTRACT_CUE_START_TIME': 2009, 'BUFFER_READ_OUT_OF_BOUNDS': 3000, 'JS_INTEGER_OVERFLOW': 3001, 'EBML_OVERFLOW': 3002, 'EBML_BAD_FLOATING_POINT_SIZE': 3003, 'MP4_SIDX_WRONG_BOX_TYPE': 3004, 'MP4_SIDX_INVALID_TIMESCALE': 3005, 'MP4_SIDX_TYPE_NOT_SUPPORTED': 3006, 'WEBM_CUES_ELEMENT_MISSING': 3007, 'WEBM_EBML_HEADER_ELEMENT_MISSING': 3008, 'WEBM_SEGMENT_ELEMENT_MISSING': 3009, 'WEBM_INFO_ELEMENT_MISSING': 3010, 'WEBM_DURATION_ELEMENT_MISSING': 3011, 'WEBM_CUE_TRACK_POSITIONS_ELEMENT_MISSING': 3012, 'WEBM_CUE_TIME_ELEMENT_MISSING': 3013, 'MEDIA_SOURCE_OPERATION_FAILED': 3014, 'MEDIA_SOURCE_OPERATION_THREW': 3015, 'VIDEO_ERROR': 3016, 'QUOTA_EXCEEDED_ERROR': 3017, 'TRANSMUXING_FAILED': 3018, 'UNABLE_TO_GUESS_MANIFEST_TYPE': 4000, 'DASH_INVALID_XML': 4001, 'DASH_NO_SEGMENT_INFO': 4002, 'DASH_EMPTY_ADAPTATION_SET': 4003, 'DASH_EMPTY_PERIOD': 4004, 'DASH_WEBM_MISSING_INIT': 4005, 'DASH_UNSUPPORTED_CONTAINER': 4006, 'DASH_PSSH_BAD_ENCODING': 4007, 'DASH_NO_COMMON_KEY_SYSTEM': 4008, 'DASH_MULTIPLE_KEY_IDS_NOT_SUPPORTED': 4009, 'DASH_CONFLICTING_KEY_IDS': 4010, 'UNPLAYABLE_PERIOD': 4011, 'RESTRICTIONS_CANNOT_BE_MET': 4012, 'NO_PERIODS': 4014, 'HLS_PLAYLIST_HEADER_MISSING': 4015, 'INVALID_HLS_TAG': 4016, 'HLS_INVALID_PLAYLIST_HIERARCHY': 4017, 'DASH_DUPLICATE_REPRESENTATION_ID': 4018, 'HLS_MULTIPLE_MEDIA_INIT_SECTIONS_FOUND': 4020, 'HLS_COULD_NOT_GUESS_MIME_TYPE': 4021, 'HLS_MASTER_PLAYLIST_NOT_PROVIDED': 4022, 'HLS_REQUIRED_ATTRIBUTE_MISSING': 4023, 'HLS_REQUIRED_TAG_MISSING': 4024, 'HLS_COULD_NOT_GUESS_CODECS': 4025, 'HLS_KEYFORMATS_NOT_SUPPORTED': 4026, 'DASH_UNSUPPORTED_XLINK_ACTUATE': 4027, 'DASH_XLINK_DEPTH_LIMIT': 4028, 'HLS_COULD_NOT_PARSE_SEGMENT_START_TIME': 4030, 'CONTENT_UNSUPPORTED_BY_BROWSER': 4032, 'CANNOT_ADD_EXTERNAL_TEXT_TO_LIVE_STREAM': 4033, 'HLS_AES_128_ENCRYPTION_NOT_SUPPORTED': 4034, 'INVALID_STREAMS_CHOSEN': 5005, 'NO_RECOGNIZED_KEY_SYSTEMS': 6000, 'REQUESTED_KEY_SYSTEM_CONFIG_UNAVAILABLE': 6001, 'FAILED_TO_CREATE_CDM': 6002, 'FAILED_TO_ATTACH_TO_VIDEO': 6003, 'INVALID_SERVER_CERTIFICATE': 6004, 'FAILED_TO_CREATE_SESSION': 6005, 'FAILED_TO_GENERATE_LICENSE_REQUEST': 6006, 'LICENSE_REQUEST_FAILED': 6007, 'LICENSE_RESPONSE_REJECTED': 6008, 'ENCRYPTED_CONTENT_WITHOUT_DRM_INFO': 6010, 'NO_LICENSE_SERVER_GIVEN': 6012, 'OFFLINE_SESSION_REMOVED': 6013, 'EXPIRED': 6014, 'LOAD_INTERRUPTED': 7000, 'OPERATION_ABORTED': 7001, 'NO_VIDEO_ELEMENT': 7002, 'CAST_API_UNAVAILABLE': 8000, 'NO_CAST_RECEIVERS': 8001, 'ALREADY_CASTING': 8002, 'UNEXPECTED_CAST_ERROR': 8003, 'CAST_CANCELED_BY_USER': 8004, 'CAST_CONNECTION_TIMED_OUT': 8005, 'CAST_RECEIVER_APP_UNAVAILABLE': 8006, 'CAST_RECEIVER_APP_ID_MISSING': 8007, 'STORAGE_NOT_SUPPORTED': 9000, 'INDEXED_DB_ERROR': 9001, 'DEPRECATED_OPERATION_ABORTED': 9002, 'REQUESTED_ITEM_NOT_FOUND': 9003, 'MALFORMED_OFFLINE_URI': 9004, 'CANNOT_STORE_LIVE_OFFLINE': 9005, 'STORE_ALREADY_IN_PROGRESS': 9006, 'NO_INIT_DATA_FOR_OFFLINE': 9007, 'LOCAL_PLAYER_INSTANCE_REQUIRED': 9008, 'NEW_KEY_OPERATION_NOT_SUPPORTED': 9011, 'KEY_NOT_FOUND': 9012, 'MISSING_STORAGE_CELL': 9013 }; /** * A utility to wrap abortable operations. Note that these are not cancelable. * Cancelation implies undoing what has been done so far, whereas aborting only * means that futher work is stopped. * @implements {shaka.extern.IAbortableOperation.<T>} * @template T */ shaka.util.AbortableOperation = class { /** * @param {!Promise.<T>} promise * A Promise which represents the underlying operation. It is resolved when * the operation is complete, and rejected if the operation fails or is * aborted. Aborted operations should be rejected with a shaka.util.Error * object using the error code OPERATION_ABORTED. * @param {function():!Promise} onAbort * Will be called by this object to abort the underlying operation. * This is not cancelation, and will not necessarily result in any work * being undone. abort() should return a Promise which is resolved when the * underlying operation has been aborted. The returned Promise should never * be rejected. */ constructor(promise,onAbort) {} /** * @param {!shaka.util.Error} error * @return {!shaka.util.AbortableOperation} An operation which has already * failed with the error given by the caller. */ static failed(error) {} /** * @return {!shaka.util.AbortableOperation} An operation which has already * failed with the error OPERATION_ABORTED. */ static aborted() {} /** * @param {U} value * @return {!shaka.util.AbortableOperation.<U>} An operation which has already * completed with the given value. * @template U */ static completed(value) {} /** * @param {!Promise.<U>} promise * @return {!shaka.util.AbortableOperation.<U>} An operation which cannot be * aborted. It will be completed when the given Promise is resolved, or * will be failed when the given Promise is rejected. * @template U */ static notAbortable(promise) {} /** * @override */ abort() {} /** * @param {!Array.<!shaka.util.AbortableOperation>} operations * @return {!shaka.util.AbortableOperation} An operation which is resolved * when all operations are successful and fails when any operation fails. * For this operation, abort() aborts all given operations. */ static all(operations) {} /** * @override */ finally(onFinal) {} /** * @param {(undefined| * function(T):U| * function(T):!Promise.<U>| * function(T):!shaka.util.AbortableOperation.<U>)} onSuccess * A callback to be invoked after this operation is complete, to chain to * another operation. The callback can return a plain value, a Promise to * an asynchronous value, or another AbortableOperation. * @param {function(*)=} onError * An optional callback to be invoked if this operation fails, to perform * some cleanup or error handling. Analogous to the second parameter of * Promise.prototype.then. * @return {!shaka.util.AbortableOperation.<U>} An operation which is resolved * when this operation and the operation started by the callback are both * complete. * @template U */ chain(onSuccess,onError) {} }; /** * @const {!Promise.<T>} */ shaka.util.AbortableOperation.prototype.promise; /** * An interface to standardize how objects are destroyed. * @interface */ shaka.util.IDestroyable = class { /** * Request that this object be destroyed, releasing all resources and shutting * down all operations. Returns a Promise which is resolved when destruction * is complete. This Promise should never be rejected. * @return {!Promise} */ destroy() {} }; /** * NetworkingEngine wraps all networking operations. This accepts plugins that * handle the actual request. A plugin is registered using registerScheme. * Each scheme has at most one plugin to handle the request. * @param {function(number, number)=} onProgressUpdated Called when a progress * event is triggered. Passed the duration, in milliseconds, that the request * took, and the number of bytes transferred. * @struct * @constructor * @implements {shaka.util.IDestroyable} * @extends {shaka.util.FakeEventTarget} */ shaka.net.NetworkingEngine = function(onProgressUpdated) {}; /** * Request types. Allows a filter to decide which requests to read/alter. * @enum {number} */ shaka.net.NetworkingEngine.RequestType = { 'MANIFEST': 0, 'SEGMENT': 1, 'LICENSE': 2, 'APP': 3, 'TIMING': 4 }; /** * Priority level for network scheme plugins. * If multiple plugins are provided for the same scheme, only the * highest-priority one is used. * @enum {number} */ shaka.net.NetworkingEngine.PluginPriority = { 'FALLBACK': 1, 'PREFERRED': 2, 'APPLICATION': 3 }; /** * Registers a scheme plugin. This plugin will handle all requests with the * given scheme. If a plugin with the same scheme already exists, it is * replaced, unless the existing plugin is of higher priority. * If no priority is provided, this defaults to the highest priority of * APPLICATION. * @param {string} scheme * @param {shaka.extern.SchemePlugin} plugin * @param {number=} priority */ shaka.net.NetworkingEngine.registerScheme = function(scheme, plugin, priority) {}; /** * Removes a scheme plugin. * @param {string} scheme */ shaka.net.NetworkingEngine.unregisterScheme = function(scheme) {}; /** * Registers a new request filter. All filters are applied in the order they * are registered. * @param {shaka.extern.RequestFilter} filter */ shaka.net.NetworkingEngine.prototype.registerRequestFilter = function(filter) {}; /** * Removes a request filter. * @param {shaka.extern.RequestFilter} filter */ shaka.net.NetworkingEngine.prototype.unregisterRequestFilter = function(filter) {}; /** * Clears all request filters. */ shaka.net.NetworkingEngine.prototype.clearAllRequestFilters = function() {}; /** * Registers a new response filter. All filters are applied in the order they * are registered. * @param {shaka.extern.ResponseFilter} filter */ shaka.net.NetworkingEngine.prototype.registerResponseFilter = function(filter) {}; /** * Removes a response filter. * @param {shaka.extern.ResponseFilter} filter */ shaka.net.NetworkingEngine.prototype.unregisterResponseFilter = function(filter) {}; /** * Clears all response filters. */ shaka.net.NetworkingEngine.prototype.clearAllResponseFilters = function() {}; /** * @override */ shaka.net.NetworkingEngine.prototype.destroy = function() {}; /** * Makes a network request and returns the resulting data. * @param {shaka.net.NetworkingEngine.RequestType} type * @param {shaka.extern.Request} request * @return {!shaka.net.NetworkingEngine.PendingRequest} */ shaka.net.NetworkingEngine.prototype.request = function(type, request) {}; /** * A wrapper class for the number of bytes remaining to be downloaded for the * request. * Instead of using PendingRequest directly, this class is needed to be sent to * plugin as a parameter, and a Promise is returned, before PendingRequest is * created. */ shaka.net.NetworkingEngine.NumBytesRemainingClass = class { /** * Constructor */ constructor() {} }; /** * A pending network request. This can track the current progress of the * download, and allows the request to be aborted if the network is slow. * @implements {shaka.extern.IAbortableOperation.<shaka.extern.Response>} * @extends {shaka.util.AbortableOperation} */ shaka.net.NetworkingEngine.PendingRequest = class extends shaka.util.AbortableOperation { /** * @param {!Promise} promise * A Promise which represents the underlying operation. It is resolved when * the operation is complete, and rejected if the operation fails or is * aborted. Aborted operations should be rejected with a shaka.util.Error * object using the error code OPERATION_ABORTED. * @param {function():!Promise} onAbort * Will be called by this object to abort the underlying operation. * This is not cancelation, and will not necessarily result in any work * being undone. abort() should return a Promise which is resolved when the * underlying operation has been aborted. The returned Promise should never * be rejected. * @param {shaka.net.NetworkingEngine.NumBytesRemainingClass} * numBytesRemainingObj */ constructor(promise,onAbort,numBytesRemainingObj) {} }; /** * An interface to standardize how objects release internal references * synchronously. If an object needs to asynchronously release references, then * it should use 'shaka.util.IDestroyable'. * @interface */ shaka.util.IReleasable = class { /** * Request that this object release all internal references. */ release() {} }; /** * @summary * An EventManager maintains a collection of "event * bindings" between event targets and event listeners. * @implements {shaka.util.IReleasable} */ shaka.util.EventManager = class { constructor() {} /** * Detaches all event listeners. * @override */ release() {} /** * Attaches an event listener to an event target. * @param {EventTarget} target The event target. * @param {string} type The event type. * @param {shaka.util.EventManager.ListenerType} listener The event listener. * @param {(boolean|!AddEventListenerOptions)=} options An object that * specifies characteristics about the event listener. * The passive option, if true, indicates that this function will never * call preventDefault(), which improves scrolling performance. */ listen(target,type,listener,options) {} /** * Attaches an event listener to an event target. The listener will be * removed when the first instance of the event is fired. * @param {EventTarget} target The event target. * @param {string} type The event type. * @param {shaka.util.EventManager.ListenerType} listener The event listener. * @param {(boolean|!AddEventListenerOptions)=} options An object that * specifies characteristics about the event listener. * The passive option, if true, indicates that this function will never * call preventDefault(), which improves scrolling performance. */ listenOnce(target,type,listener,options) {} /** * Detaches an event listener from an event target. * @param {EventTarget} target The event target. * @param {string} type The event type. * @param {shaka.util.EventManager.ListenerType=} listener The event listener. */ unlisten(target,type,listener) {} /** * Detaches all event listeners from all targets. */ removeAll() {} }; /** * @typedef {function(!Event)} */ shaka.util.EventManager.ListenerType; /** * Creates a string from the given buffer as UTF-8 encoding. * @param {?BufferSource} data * @return {string} * @throws {shaka.util.Error} */ shaka.util.StringUtils.fromUTF8 = function(data) {}; /** * Creates a string from the given buffer as UTF-16 encoding. * @param {?BufferSource} data * @param {boolean} littleEndian true to read little endian, false to read big. * @param {boolean=} noThrow true to avoid throwing in cases where we may * expect invalid input. If noThrow is true and the data has an odd length, * it will be truncated. * @return {string} * @throws {shaka.util.Error} */ shaka.util.StringUtils.fromUTF16 = function(data, littleEndian, noThrow) {}; /** * Creates a string from the given buffer, auto-detecting the encoding that is * being used. If it cannot detect the encoding, it will throw an exception. * @param {?BufferSource} data * @return {string} * @throws {shaka.util.Error} */ shaka.util.StringUtils.fromBytesAutoDetect = function(data) {}; /** * Creates a ArrayBuffer from the given string, converting to UTF-8 encoding. * @param {string} str * @return {!ArrayBuffer} */ shaka.util.StringUtils.toUTF8 = function(str) {}; /** * Creates a ArrayBuffer from the given string, converting to UTF-16 encoding. * @param {string} str * @param {boolean} littleEndian * @return {!ArrayBuffer} */ shaka.util.StringUtils.toUTF16 = function(str, littleEndian) {}; /** * Convert a Uint8Array to a base64 string. The output will always use the * alternate encoding/alphabet also known as "base64url". * @param {!Uint8Array} arr * @param {boolean=} padding If true, pad the output with equals signs. * Defaults to true. * @return {string} */ shaka.util.Uint8ArrayUtils.toBase64 = function(arr, padding) {}; /** * Convert a base64 string to a Uint8Array. Accepts either the standard * alphabet or the alternate "base64url" alphabet. * @param {string} str * @return {!Uint8Array} */ shaka.util.Uint8ArrayUtils.fromBase64 = function(str) {}; /** * Convert a hex string to a Uint8Array. * @param {string} str * @return {!Uint8Array} */ shaka.util.Uint8ArrayUtils.fromHex = function(str) {}; /** * Convert a Uint8Array to a hex string. * @param {!Uint8Array} arr * @return {string} */ shaka.util.Uint8ArrayUtils.toHex = function(arr) {}; /** * Compare two Uint8Arrays for equality. * @param {Uint8Array} arr1 * @param {Uint8Array} arr2 * @return {boolean} */ shaka.util.Uint8ArrayUtils.equal = function(arr1, arr2) {}; /** * Concatenate Uint8Arrays. * @param {...!Uint8Array} varArgs * @return {!Uint8Array} */ shaka.util.Uint8ArrayUtils.concat = function(...varArgs) {}; /** * Creates a Cue object. * @param {number} startTime * @param {number} endTime * @param {string} payload * @implements {shaka.extern.Cue} * @constructor * @struct */ shaka.text.Cue = function(startTime, endTime, payload) {}; /** * @override */ shaka.text.Cue.prototype.startTime; /** * @override */ shaka.text.Cue.prototype.direction; /** * @override */ shaka.text.Cue.prototype.endTime; /** * @override */ shaka.text.Cue.prototype.payload; /** * @override */ shaka.text.Cue.prototype.region; /** * @override */ shaka.text.Cue.prototype.position; /** * @override */ shaka.text.Cue.prototype.positionAlign; /** * @override */ shaka.text.Cue.prototype.size; /** * @override */ shaka.text.Cue.prototype.textAlign; /** * @override */ shaka.text.Cue.prototype.writingMode; /** * @override */ shaka.text.Cue.prototype.lineInterpretation; /** * @override */ shaka.text.Cue.prototype.line; /** * @override */ shaka.text.Cue.prototype.lineHeight; /** * Line Alignment is set to start by default. * @override */ shaka.text.Cue.prototype.lineAlign; /** * Set the captions at the bottom of the text container by default. * @override */ shaka.text.Cue.prototype.displayAlign; /** * @override */ shaka.text.Cue.prototype.color; /** * @override */ shaka.text.Cue.prototype.backgroundColor; /** * @override */ shaka.text.Cue.prototype.backgroundImage; /** * @override */ shaka.text.Cue.prototype.fontSize; /** * @override */ shaka.text.Cue.prototype.fontWeight; /** * @override */ shaka.text.Cue.prototype.fontStyle; /** * @override */ shaka.text.Cue.prototype.fontFamily; /** * @override */ shaka.text.Cue.prototype.textDecoration; /** * @override */ shaka.text.Cue.prototype.wrapLine; /** * @override */ shaka.text.Cue.prototype.id; /** * @enum {string} */ shaka.text.Cue.positionAlign = { 'LEFT': 'line-left', 'RIGHT': 'line-right', 'CENTER': 'center', 'AUTO': 'auto' }; /** * @enum {string} */ shaka.text.Cue.textAlign = { 'LEFT': 'left', 'RIGHT': 'right', 'CENTER': 'center', 'START': 'start', 'END': 'end' }; /** * Vertical alignments of the cues within their extents. * 'BEFORE' means displaying at the top of the captions container box, 'CENTER' * means in the middle, 'BOTTOM' means at the bottom. * @enum {string} */ shaka.text.Cue.displayAlign = { 'BEFORE': 'before', 'CENTER': 'center', 'AFTER': 'after' }; /** * @enum {string} */ shaka.text.Cue.direction = { 'HORIZONTAL_LEFT_TO_RIGHT': 'ltr', 'HORIZONTAL_RIGHT_TO_LEFT': 'rtl' }; /** * @enum {string} */ shaka.text.Cue.writingMode = { 'HORIZONTAL_TOP_TO_BOTTOM': 'horizontal-tb', 'VERTICAL_LEFT_TO_RIGHT': 'vertical-lr', 'VERTICAL_RIGHT_TO_LEFT': 'vertical-rl' }; /** * @enum {number} */ shaka.text.Cue.lineInterpretation = { 'LINE_NUMBER': 0, 'PERCENTAGE': 1 }; /** * @enum {string} */ shaka.text.Cue.lineAlign = { 'CENTER': 'center', 'START': 'start', 'END': 'end' }; /** * In CSS font weight can be a number, where 400 is normal and 700 is bold. * Use these values for the enum for consistency. * @enum {number} */ shaka.text.Cue.fontWeight = { 'NORMAL': 400, 'BOLD': 700 }; /** * @enum {string} */ shaka.text.Cue.fontStyle = { 'NORMAL': 'normal', 'ITALIC': 'italic', 'OBLIQUE': 'oblique' }; /** * @enum {string} */ shaka.text.Cue.textDecoration = { 'UNDERLINE': 'underline', 'LINE_THROUGH': 'lineThrough', 'OVERLINE': 'overline' }; /** * Creates a CueRegion object. * @implements {shaka.extern.CueRegion} * @constructor * @struct */ shaka.text.CueRegion = function() {}; /** * @override */ shaka.text.CueRegion.prototype.id; /** * @override */ shaka.text.CueRegion.prototype.viewportAnchorX; /** * @override */ shaka.text.CueRegion.prototype.viewportAnchorY; /** * @override */ shaka.text.CueRegion.prototype.regionAnchorX; /** * @override */ shaka.text.CueRegion.prototype.regionAnchorY; /** * @override */ shaka.text.CueRegion.prototype.width; /** * @override */ shaka.text.CueRegion.prototype.height; /** * @override */ shaka.text.CueRegion.prototype.heightUnits; /** * @override */ shaka.text.CueRegion.prototype.widthUnits; /** * @override */ shaka.text.CueRegion.prototype.viewportAnchorUnits; /** * @override */ shaka.text.CueRegion.prototype.scroll; /** * @enum {number} */ shaka.text.CueRegion.units = { 'PX': 0, 'PERCENTAGE': 1, 'LINES': 2 }; /** * @enum {string} */ shaka.text.CueRegion.scrollMode = { 'NONE': '', 'UP': 'up' }; /** * @param {string} mimeType * @param {!shaka.extern.TextParserPlugin} plugin */ shaka.text.TextEngine.registerParser = function(mimeType, plugin) {}; /** * @param {string} mimeType */ shaka.text.TextEngine.unregisterParser = function(mimeType) {}; /** * Append cues to text displayer. * @param {!Array.<!shaka.text.Cue>} cues */ shaka.text.TextEngine.prototype.appendCues = function(cues) {}; /** * Set the selected closed captions id. * Append the cues stored in the closed captions map until buffer end time. * This is to fill the gap between buffered and unbuffered captions, and to * avoid duplicates that would be caused by any future video segments parsed for * captions. * @param {string} id * @param {number} bufferEndTime Load any stored cues up to this time. */ shaka.text.TextEngine.prototype.setSelectedClosedCaptionId = function(id, bufferEndTime) {}; /** * <p> * This defines the default ABR manager for the Player. An instance of this * class is used when no ABR manager is given. * </p> * <p> * The behavior of this class is to take throughput samples using * segmentDownloaded to estimate the current network bandwidth. Then it will * use that to choose the streams that best fit the current bandwidth. It will * always pick the highest bandwidth variant it thinks can be played. * </p> * <p> * After initial choices are made, this class will call switchCallback() when * there is a better choice. switchCallback() will not be called more than once * per ({@link shaka.abr.SimpleAbrManager.SWITCH_INTERVAL_MS}). * </p> * @constructor * @struct * @implements {shaka.extern.AbrManager} */ shaka.abr.SimpleAbrManager = function() {}; /** * @override */ shaka.abr.SimpleAbrManager.prototype.stop = function() {}; /** * @override */ shaka.abr.SimpleAbrManager.prototype.init = function(switchCallback) {}; /** * @override */ shaka.abr.SimpleAbrManager.prototype.chooseVariant = function() {}; /** * @override */ shaka.abr.SimpleAbrManager.prototype.enable = function() {}; /** * @override */ shaka.abr.SimpleAbrManager.prototype.disable = function() {}; /** * @override */ shaka.abr.SimpleAbrManager.prototype.segmentDownloaded = function(deltaTimeMs, numBytes) {}; /** * @override */ shaka.abr.SimpleAbrManager.prototype.getBandwidthEstimate = function() {}; /** * @override */ shaka.abr.SimpleAbrManager.prototype.setVariants = function(variants) {}; /** * @override */ shaka.abr.SimpleAbrManager.prototype.configure = function(config) {}; /** * A proxy to switch between local and remote playback for Chromecast in a way * that is transparent to the app's controls. * @constructor * @struct * @param {!HTMLMediaElement} video The local video element associated with the * local Player instance. * @param {!shaka.Player} player A local Player instance. * @param {string} receiverAppId The ID of the cast receiver application. * If blank, casting will not be available, but the proxy will still function * otherwise. * @implements {shaka.util.IDestroyable} * @extends {shaka.util.FakeEventTarget} */ shaka.cast.CastProxy = function(video, player, receiverAppId) {}; /** * Destroys the proxy and the underlying local Player. * @param {boolean=} forceDisconnect If true, force the receiver app to shut * down by disconnecting. Does nothing if not connected. * @override */ shaka.cast.CastProxy.prototype.destroy = function(forceDisconnect) {}; /** * Get a proxy for the video element that delegates to local and remote video * elements as appropriate. * @suppress {invalidCasts} to cast proxy Objects to unrelated types * @return {!HTMLMediaElement} */ shaka.cast.CastProxy.prototype.getVideo = function() {}; /** * Get a proxy for the Player that delegates to local and remote Player objects * as appropriate. * @suppress {invalidCasts} to cast proxy Objects to unrelated types * @return {!shaka.Player} */ shaka.cast.CastProxy.prototype.getPlayer = function() {}; /** * @return {boolean} True if the cast API is available and there are receivers. */ shaka.cast.CastProxy.prototype.canCast = function() {}; /** * @return {boolean} True if we are currently casting. */ shaka.cast.CastProxy.prototype.isCasting = function() {}; /** * @return {string} The name of the Cast receiver device, if isCasting(). */ shaka.cast.CastProxy.prototype.receiverName = function() {}; /** * @return {!Promise} Resolved when connected to a receiver. Rejected if the * connection fails or is canceled by the user. */ shaka.cast.CastProxy.prototype.cast = function() {}; /** * Set application-specific data. * @param {Object} appData Application-specific data to relay to the receiver. */ shaka.cast.CastProxy.prototype.setAppData = function(appData) {}; /** * Show a dialog where user can choose to disconnect from the cast connection. */ shaka.cast.CastProxy.prototype.suggestDisconnect = function() {}; /** * @param {string} newAppId */ shaka.cast.CastProxy.prototype.changeReceiverId = function(newAppId) {}; /** * Force the receiver app to shut down by disconnecting. */ shaka.cast.CastProxy.prototype.forceDisconnect = function() {}; /** * A receiver to communicate between the Chromecast-hosted player and the * sender application. * @constructor * @struct * @param {!HTMLMediaElement} video The local video element associated with the * local Player instance. * @param {!shaka.Player} player A local Player instance. * @param {function(Object)=} appDataCallback A callback to handle * application-specific data passed from the sender. This can come either * from a Shaka-based sender through CastProxy.setAppData, or from a * sender using the customData field of the LOAD message of the standard * Cast message namespace. It can also be null if no such data is sent. * @param {function(string):string=} contentIdCallback A callback to * retrieve manifest URI from the provided content id. * @implements {shaka.util.IDestroyable} * @extends {shaka.util.FakeEventTarget} */ shaka.cast.CastReceiver = function(video, player, appDataCallback, contentIdCallback) {}; /** * @return {boolean} True if the cast API is available and there are receivers. */ shaka.cast.CastReceiver.prototype.isConnected = function() {}; /** * @return {boolean} True if the receiver is not currently doing loading or * playing anything. */ shaka.cast.CastReceiver.prototype.isIdle = function() {}; /** * Destroys the underlying Player, then terminates the cast receiver app. * @override */ shaka.cast.CastReceiver.prototype.destroy = function() {}; /** * Creates an InitSegmentReference, which provides the location to an * initialization segment. * @param {function():!Array.<string>} uris A function that creates the URIs of * the resource containing the segment. * @param {number} startByte The offset from the start of the resource to the * start of the segment. * @param {?number} endByte The offset from the start of the resource to the * end of the segment, inclusive. A value of null indicates that the segment * extends to the end of the resource. * @constructor * @struct */ shaka.media.InitSegmentReference = function(uris, startByte, endByte) {}; /** * Creates the URIs of the resource containing the segment. * @return {!Array.<string>} */ shaka.media.InitSegmentReference.prototype.createUris = function() {}; /** * Returns the offset from the start of the resource to the * start of the segment. * @return {number} */ shaka.media.InitSegmentReference.prototype.getStartByte = function() {}; /** * Returns the offset from the start of the resource to the end of the segment, * inclusive. A value of null indicates that the segment extends to the end of * the resource. * @return {?number} */ shaka.media.InitSegmentReference.prototype.getEndByte = function() {}; /** * Creates a SegmentReference, which provides the start time, end time, and * location to a media segment. * @param {number} position The segment's position within a particular Period. * The following should hold true between any two SegmentReferences from the * same Period, r1 and r2: * IF r2.position > r1.position THEN * [ (r2.startTime > r1.startTime) OR * (r2.startTime == r1.startTime AND r2.endTime >= r1.endTime) ] * @param {number} startTime The segment's start time in seconds, relative to * the start of a particular Period. * @param {number} endTime The segment's end time in seconds, relative to * the start of a particular Period. The segment ends the instant before * this time, so |endTime| must be strictly greater than |startTime|. * @param {function():!Array.<string>} uris * A function that creates the URIs of the resource containing the segment. * @param {number} startByte The offset from the start of the resource to the * start of the segment. * @param {?number} endByte The offset from the start of the resource to the * end of the segment, inclusive. A value of null indicates that the segment * extends to the end of the resource. * @constructor * @struct */ shaka.media.SegmentReference = function(position, startTime, endTime, uris, startByte, endByte) {}; /** * Returns the segment's position within a particular Period. * @return {number} The segment's position. */ shaka.media.SegmentReference.prototype.getPosition = function() {}; /** * Returns the segment's start time in seconds, relative to * the start of a particular Period. * @return {number} */ shaka.media.SegmentReference.prototype.getStartTime = function() {}; /** * Returns the segment's end time in seconds, relative to * the start of a particular Period. * @return {number} */ shaka.media.SegmentReference.prototype.getEndTime = function() {}; /** * Creates the URIs of the resource containing the segment. * @return {!Array.<string>} */ shaka.media.SegmentReference.prototype.createUris = function() {}; /** * Returns the offset from the start of the resource to the * start of the segment. * @return {number} */ shaka.media.SegmentReference.prototype.getStartByte = function() {}; /** * Returns the offset from the start of the resource to the end of the segment, * inclusive. A value of null indicates that the segment extends to the end of * the resource. * @return {?number} */ shaka.media.SegmentReference.prototype.getEndByte = function() {}; /** * Creates a DataViewReader, which abstracts a DataView object. * @param {!DataView} dataView The DataView. * @param {shaka.util.DataViewReader.Endianness} endianness The endianness. * @struct * @constructor */ shaka.util.DataViewReader = function(dataView, endianness) {}; /** * Endianness. * @enum {number} */ shaka.util.DataViewReader.Endianness = { BIG_ENDIAN: 0, LITTLE_ENDIAN: 1 }; /** * @return {boolean} True if the reader has more data, false otherwise. */ shaka.util.DataViewReader.prototype.hasMoreData = function() {}; /** * Gets the current byte position. * @return {number} */ shaka.util.DataViewReader.prototype.getPosition = function() {}; /** * Gets the byte length of the DataView. * @return {number} */ shaka.util.DataViewReader.prototype.getLength = function() {}; /** * Reads an unsigned 8 bit integer, and advances the reader. * @return {number} The integer. * @throws {shaka.util.Error} when reading past the end of the data view. */ shaka.util.DataViewReader.prototype.readUint8 = function() {}; /** * Reads an unsigned 16 bit integer, and advances the reader. * @return {number} The integer. * @throws {shaka.util.Error} when reading past the end of the data view. */ shaka.util.DataViewReader.prototype.readUint16 = function() {}; /** * Reads an unsigned 32 bit integer, and advances the reader. * @return {number} The integer. * @throws {shaka.util.Error} when reading past the end of the data view. */ shaka.util.DataViewReader.prototype.readUint32 = function() {}; /** * Reads a signed 32 bit integer, and advances the reader. * @return {number} The integer. * @throws {shaka.util.Error} when reading past the end of the data view. */ shaka.util.DataViewReader.prototype.readInt32 = function() {}; /** * Reads an unsigned 64 bit integer, and advances the reader. * @return {number} The integer. * @throws {shaka.util.Error} when reading past the end of the data view or * when reading an integer too large to store accurately in JavaScript. */ shaka.util.DataViewReader.prototype.readUint64 = function() {}; /** * Reads the specified number of raw bytes. * @param {number} bytes The number of bytes to read. * @return {!Uint8Array} * @throws {shaka.util.Error} when reading past the end of the data view. */ shaka.util.DataViewReader.prototype.readBytes = function(bytes) {}; /** * Skips the specified number of bytes. * @param {number} bytes The number of bytes to skip. * @throws {shaka.util.Error} when skipping past the end of the data view. */ shaka.util.DataViewReader.prototype.skip = function(bytes) {}; /** * Rewinds the specified number of bytes. * @param {number} bytes The number of bytes to rewind. * @throws {shaka.util.Error} when rewinding past the beginning of the data * view. */ shaka.util.DataViewReader.prototype.rewind = function(bytes) {}; /** * Seeks to a specified position. * @param {number} position The desired byte position within the DataView. * @throws {shaka.util.Error} when seeking outside the range of the data view. */ shaka.util.DataViewReader.prototype.seek = function(position) {}; /** * Keeps reading until it reaches a byte that equals to zero. The text is * assumed to be UTF-8. * @return {string} */ shaka.util.DataViewReader.prototype.readTerminatedString = function() {}; /** * Create a new MP4 Parser * @struct * @constructor */ shaka.util.Mp4Parser = function() {}; /** * @typedef {function(!shaka.extern.ParsedBox)} */ shaka.util.Mp4Parser.CallbackType; /** * Declare a box type as a Box. * @param {string} type * @param {!shaka.util.Mp4Parser.CallbackType} definition * @return {!shaka.util.Mp4Parser} */ shaka.util.Mp4Parser.prototype.box = function(type, definition) {}; /** * Declare a box type as a Full Box. * @param {string} type * @param {!shaka.util.Mp4Parser.CallbackType} definition * @return {!shaka.util.Mp4Parser} */ shaka.util.Mp4Parser.prototype.fullBox = function(type, definition) {}; /** * Stop parsing. Useful for extracting information from partial segments and * avoiding an out-of-bounds error once you find what you are looking for. */ shaka.util.Mp4Parser.prototype.stop = function() {}; /** * Parse the given data using the added callbacks. * @param {!BufferSource} data * @param {boolean=} partialOkay If true, allow reading partial payloads * from some boxes. If the goal is a child box, we can sometimes find it * without enough data to find all child boxes. */ shaka.util.Mp4Parser.prototype.parse = function(data, partialOkay) {}; /** * Parse the next box on the current level. * @param {number} absStart The absolute start position in the original * byte array. * @param {!shaka.util.DataViewReader} reader * @param {boolean=} partialOkay If true, allow reading partial payloads * from some boxes. If the goal is a child box, we can sometimes find it * without enough data to find all child boxes. */ shaka.util.Mp4Parser.prototype.parseNext = function(absStart, reader, partialOkay) {}; /** * A callback that tells the Mp4 parser to treat the body of a box as a series * of boxes. The number of boxes is limited by the size of the parent box. * @param {!shaka.extern.ParsedBox} box */ shaka.util.Mp4Parser.children = function(box) {}; /** * A callback that tells the Mp4 parser to treat the body of a box as a sample * description. A sample description box has a fixed number of children. The * number of children is represented by a 4 byte unsigned integer. Each child * is a box. * @param {!shaka.extern.ParsedBox} box */ shaka.util.Mp4Parser.sampleDescription = function(box) {}; /** * Create a callback that tells the Mp4 parser to treat the body of a box as a * binary blob and to parse the body's contents using the provided callback. * @param {function(!Uint8Array)} callback * @return {!shaka.util.Mp4Parser.CallbackType} */ shaka.util.Mp4Parser.allData = function(callback) {}; /** * Convert an integer type from a box into an ascii string name. * Useful for debugging. * @param {number} type The type of the box, a uint32. * @return {string} */ shaka.util.Mp4Parser.typeToString = function(type) {}; /** * Creates a SegmentIndex. * @param {!Array.<!shaka.media.SegmentReference>} references The list of * SegmentReferences, which must be sorted first by their start times * (ascending) and second by their end times (ascending). They must have * continuous, increasing positions. * @constructor * @struct * @implements {shaka.util.IDestroyable} */ shaka.media.SegmentIndex = function(references) {}; /** * @override */ shaka.media.SegmentIndex.prototype.destroy = function() {}; /** * Finds the position of the segment for the given time, in seconds, relative * to the start of a particular Period. Returns the position of the segment * with the largest end time if more than one segment is known for the given * time. * @param {number} time * @return {?number} The position of the segment, or null * if the position of the segment could not be determined. */ shaka.media.SegmentIndex.prototype.find = function(time) {}; /** * Gets the SegmentReference for the segment at the given position. * @param {number} position The position of the segment. * @return {shaka.media.SegmentReference} The SegmentReference, or null if * no such SegmentReference exists. */ shaka.media.SegmentIndex.prototype.get = function(position) {}; /** * Offset all segment references by a fixed amount. * @param {number} offset The amount to add to each segment's start and end * times. */ shaka.media.SegmentIndex.prototype.offset = function(offset) {}; /** * Merges the given SegmentReferences. Supports extending the original * references only. Will not replace old references or interleave new ones. * @param {!Array.<!shaka.media.SegmentReference>} references The list of * SegmentReferences, which must be sorted first by their start times * (ascending) and second by their end times (ascending). They must have * continuous, increasing positions. */ shaka.media.SegmentIndex.prototype.merge = function(references) {}; /** * Removes all SegmentReferences that end before the given time. * @param {number} time The time in seconds. */ shaka.media.SegmentIndex.prototype.evict = function(time) {}; /** * Registers a manifest parser by file extension. * @param {string} extension The file extension of the manifest. * @param {shaka.extern.ManifestParser.Factory} parserFactory The factory * used to create parser instances. */ shaka.media.ManifestParser.registerParserByExtension = function(extension, parserFactory) {}; /** * Registers a manifest parser by MIME type. * @param {string} mimeType The MIME type of the manifest. * @param {shaka.extern.ManifestParser.Factory} parserFactory The factory * used to create parser instances. */ shaka.media.ManifestParser.registerParserByMime = function(mimeType, parserFactory) {}; /** * Creates a PresentationTimeline. * @param {?number} presentationStartTime The wall-clock time, in seconds, * when the presentation started or will start. Only required for live. * @param {number} presentationDelay The delay to give the presentation, in * seconds. Only required for live. * @param {boolean=} autoCorrectDrift Whether to account for drift when * determining the availability window. * @see {shaka.extern.Manifest} * @see {@tutorial architecture}