@playkit-js/playkit-js
Version:
[](https://github.com/kaltura/playkit-js/actions/workflows/run_canary.yaml) [ • 125 kB
TypeScript
import { ILogger } from 'js-logger';
import { ILogHandler } from 'js-logger';
import { ILogLevel } from 'js-logger';
export declare const AbrMode: {
readonly MANUAL: "manual";
readonly AUTO: "auto";
};
export declare const AdBreakType: {
readonly PRE: "preroll";
readonly MID: "midroll";
readonly POST: "postroll";
readonly OVERLAY: "overlay";
};
export declare const AdEventType: {
/**
* Fired when the ad can be skip by the user.
*/
readonly AD_CAN_SKIP: "adcanskip";
/**
* Fired when the ad manifest has been loaded.
*/
readonly AD_MANIFEST_LOADED: "admanifestloaded";
/**
* Fired when ad data is available.
*/
readonly AD_LOADED: "adloaded";
/**
* Fired when the ad starts playing.
*/
readonly AD_STARTED: "adstarted";
/**
* Fired when the ad is resumed.
*/
readonly AD_RESUMED: "adresumed";
/**
* Fired when the ad is paused.
*/
readonly AD_PAUSED: "adpaused";
/**
* Fired when the ad is clicked.
*/
readonly AD_CLICKED: "adclicked";
/**
* Fired when the ad is skipped by the user.
*/
readonly AD_SKIPPED: "adskipped";
/**
* Fired when the ad completes playing.
*/
readonly AD_COMPLETED: "adcompleted";
/**
* Fired when an error occurred while the ad was loading or playing.
*/
readonly AD_ERROR: "aderror";
/**
* Fired when the ads plugin is done playing all own ads.
*/
readonly ADS_COMPLETED: "adscompleted";
/**
* Fired when the ads manager is done playing all the ads.
*/
readonly ALL_ADS_COMPLETED: "alladscompleted";
/**
* Fired when content should be paused. This usually happens right before an ad is about to cover the content.
*/
readonly AD_BREAK_START: "adbreakstart";
/**
* Fired when content should be resumed. This usually happens when an ad finishes or collapses.
*/
readonly AD_BREAK_END: "adbreakend";
/**
* Fired when the ad playhead crosses first quartile.
*/
readonly AD_FIRST_QUARTILE: "adfirstquartile";
/**
* Fired when the ad playhead crosses midpoint.
*/
readonly AD_MIDPOINT: "admidpoint";
/**
* Fired when the ad playhead crosses third quartile.
*/
readonly AD_THIRD_QUARTILE: "adthirdquartile";
/**
* Fired when the ad is closed by the user.
*/
readonly USER_CLOSED_AD: "userclosedad";
/**
* Fired when the ad volume has changed.
*/
readonly AD_VOLUME_CHANGED: "advolumechanged";
/**
* Fired when the ad volume has been muted.
*/
readonly AD_MUTED: "admuted";
/**
* Fired on ad time progress.
*/
readonly AD_PROGRESS: "adprogress";
/**
* Fired when the ad has stalled playback to buffer.
*/
readonly AD_BUFFERING: "adbuffering";
/**
* Fired when an ad waterfalling occurred
*/
readonly AD_WATERFALLING: "adwaterfalling";
/**
* Fired when an ad waterfalling failed
*/
readonly AD_WATERFALLING_FAILED: "adwaterfallingfailed";
/**
* Fires when browser fails to autoplay an ad.
*/
readonly AD_AUTOPLAY_FAILED: "adautoplayfailed";
};
export declare const AdTagType: {
readonly VAST: "vast";
readonly VMAP: "vmap";
};
/**
* Audio track representation of the player.
* @classdesc
*/
export declare class AudioTrack extends Track {
/**
* The kind of the track. i.e. description, main.
* @member
* @type {AudioTrackKind}
* @private
*/
private _kind;
/**
* The flavor ID of the track.
* @member
* @type {string | undefined}
* @private
*/
private _flavorId;
/**
* Getter for the kind value of the track.
* @public
* @returns {AudioTrackKind} - The kind value of the track.
*/
get kind(): AudioTrackKind;
/**
* Getter for the flavor ID of the track.
* @public
* @returns {string | undefined} - The flavor ID of the track.
*/
get flavorId(): string | undefined;
/**
* Setter for the kind value of the track.
* @public
* @param {AudioTrackKind} value - The kind of the track.
*/
set kind(value: AudioTrackKind);
/**
* Setter for the flavor ID of the track.
* @public
* @param {string | undefined} value - The flavor ID of the track.
*/
set flavorId(value: string | undefined);
/**
* @constructor
* @param {Object} settings - The track settings object.
*/
constructor(settings?: any);
}
export declare enum AudioTrackKind {
MAIN = "main",
DESCRIPTION = "description"
}
export declare const AutoPlayType: PKAutoPlayTypes;
export declare class BaseMediaSourceAdapter extends FakeEventTarget implements IMediaSourceAdapter {
/**
* The id of the adapter.
* @member {string} id
* @static
* @private
*/
static id: string;
/**
* Passing the getLogger function to the actual media source adapter.
* @type {Function}
* @static
*/
static getLogger: (name?: string) => ILogger;
protected static _logger: ILogger;
/**
* The adapter config.
* @member {Object} _config
* @private
*/
protected _config: any;
/**
* The source object.
* @member {PKMediaSourceObject} _sourceObj
* @private
*/
protected _sourceObj?: PKMediaSourceObject;
/**
* The dom video element.
* @member {HTMLVideoElement} _videoElement
* @private
*/
protected _videoElement: HTMLVideoElement;
/**
* The adapter capabilities
* @private
*/
protected _capabilities: PKMediaSourceCapabilities;
/**
* The event manager of the adapter.
* @type {EventManager}
* @private
*/
protected _eventManager: EventManager;
/**
* The load promise
* @member {Promise<{tracks: Array<Track>}>} - _loadPromise
* @type {Promise<{tracks: Array<Track>}>}
* @private
*/
protected _loadPromise: Promise<{
tracks: Array<Track>;
}> | undefined;
/**
* The duration change handler.
* @type {Function}
* @private
*/
private _onDurationChanged;
/**
* Checks if the media source adapter is supported.
* @function isSupported
* @returns {boolean} - Whether the media source adapter is supported.
* @static
*/
static isSupported(): boolean;
/**
* check for media source supported on browser
* @static
* @returns {boolean} - Whether the media source is supported.
*/
static isMSESupported(): boolean;
/**
* @constructor
* @param {HTMLVideoElement} videoElement - The video element which bind to media source adapter.
* @param {PKMediaSourceObject} source - The source object.
* @param {Object} config - The media source adapter configuration.
*/
constructor(videoElement: HTMLVideoElement, source: PKMediaSourceObject, config?: any);
/**
* Destroys the media source adapter.
* @function destroy
* @returns {void}
*/
destroy(): Promise<void>;
/**
* Triggers the appropriate track changed event.
* @param {Track} track - The selected track.
* @private
* @returns {void}
*/
protected _onTrackChanged(track: VideoTrack | AudioTrack | TextTrack_2 | ImageTrack): void;
/**
* Dispatch an adapter event forward.
* @param {string} name - The name of the event.
* @param {?Object} payload - The event payload.
* @returns {void}
*/
protected _trigger(name: string, payload?: any): void;
/** Must implemented methods by the derived media source adapter **/
static canPlayType(mimeType: string, preferNative: boolean): boolean;
applyTextTrackStyles(sheet: CSSStyleSheet, styles: TextStyle, containerId: string, engineClassName?: string): void;
load(): Promise<{
tracks: Track[];
}>;
selectVideoTrack(videoTrack: VideoTrack): void;
selectAudioTrack(audioTrack: AudioTrack): void;
selectTextTrack(textTrack: TextTrack_2): void;
selectImageTrack(imageTrack: ImageTrack): void;
hideTextTrack(): void;
enableAdaptiveBitrate(): void;
isAdaptiveBitrateEnabled(): boolean;
applyABRRestriction(restrictions: PKABRRestrictionObject): void;
protected _getLiveEdge(): number;
seekToLiveEdge(): void;
isLive(): boolean;
isOnLiveEdge(): boolean;
setMaxBitrate(bitrate: number): void;
attachMediaSource(): void;
detachMediaSource(): void;
/**
* Handling live time update (as is not triggered when video is paused, but the current time changed)
* @function _handleLiveTimeUpdate
* @returns {void}
* @private
*/
private _handleLiveTimeUpdate;
/**
* Disables all the existing text tracks.
* @public
* @returns {void}
*/
disableNativeTextTracks(): void;
/**
* Checks if the adapter can recover from an error triggered by the video element error
* @param {Event} event - the html5 video element error
* @returns {boolean} - if it can recover or not
* @public
*/
handleMediaError(event?: MediaError): boolean;
getStartTimeOfDvrWindow(): number;
getThumbnail(time: number): ThumbnailInfo | null;
getSegmentDuration(): number;
get liveDuration(): number;
/**
* throw a run time error
* @param {string} name of the unimplemented function
* @returns {any} void/string/boolean
*/
private static _throwNotImplementedError;
/**
* Getter for the src that the adapter plays on the video element.
* In case the adapter preformed a load it will return the manifest url.
* @public
* @returns {string} - The src url.
*/
get src(): string;
/**
* Setter for the src that the adapter plays on the video element.
* @param {string} source - The src url.
* @public
* @returns {void}
*/
set src(source: string);
/**
* @public
* @return {PKMediaSourceCapabilities} - The adapter capabilities.
*/
get capabilities(): PKMediaSourceCapabilities;
get targetBuffer(): number;
getDrmInfo(): PKDrmDataObject | null;
setCachedUrls(cachedUrls: string[]): void;
}
/**
* Base middleware.
* @classdesc
*/
export declare class BaseMiddleware {
/**
* Id of the middleware instance.
* @public
*/
id: string;
/**
* Calls the next handler in the middleware chain.
* @param {Function} next - The next handler in the middleware chain.
* @returns {void}
*/
callNext(next: (...args: any[]) => any): void;
}
/**
* @param {Array<any>} list The array to search.
* @param {Function} comparisonFn
* Called and provided a candidate item as the first argument.
* Should return:
* > -1 if the item should be located at a lower index than the provided item.
* > 1 if the item should be located at a higher index than the provided item.
* > 0 if the item is the item you're looking for.
*
* @return {any} The object if it is found or null otherwise.
*/
declare function binarySearch<T>(list?: Array<T>, comparisonFn?: ((param: T) => number)): T | null;
export declare type CapabilityResult = {
[capabilityName: string]: any;
};
declare type CategoryType = {
[category: string]: number;
};
declare type CodeType = {
[code: string]: number;
};
export declare const CorsType: {
readonly ANONYMOUS: "anonymous";
readonly USE_CREDENTIALS: "use-credentials";
};
/**
* Create a standard TextTrackCue.
* @param {TimedMetadata} timedMetadata - timed metadata object.
* @returns {TextTrackCue} - the created text track cue
* @private
*/
export declare function createTextTrackCue(timedMetadata: TimedMetadata): PKTextTrackCue | null;
/**
* Create a timed metadata object from a standard TextTrackCue.
* @param {TextTrackCue} cue - text track cue.
* @returns {?TimedMetadata} - the created timed metadata object.
* @private
*/
export declare function createTimedMetadata(cue: TextTrackCue): TimedMetadata | null;
export declare const CustomEventType: {
/**
* Fires when the media is loaded.
*/
readonly MEDIA_LOADED: "medialoaded";
/**
* Fires when the player ends reset operation.
*/
readonly PLAYER_RESET: "playerreset";
/**
* Fires when the player ends destroy operation.
*/
readonly PLAYER_DESTROY: "playerdestroy";
/**
* Fires when the player enters fullscreen.
*/
readonly ENTER_FULLSCREEN: "enterfullscreen";
/**
* Fires when the player exits fullscreen.
*/
readonly EXIT_FULLSCREEN: "exitfullscreen";
/**
* Fires when browser fails to play.
*/
readonly PLAY_FAILED: "playfailed";
/**
* Fires when browser fails to autoplay with sound.
*/
readonly AUTOPLAY_FAILED: "autoplayfailed";
/**
* Fires when browser fails to autoplay with sound but start muted autoplay instead.
*/
readonly FALLBACK_TO_MUTED_AUTOPLAY: "fallbacktomutedautoplay";
/**
* Fires when change source flow started.
*/
readonly CHANGE_SOURCE_STARTED: "changesourcestarted";
/**
* Fires when change source flow ended.
*/
readonly CHANGE_SOURCE_ENDED: "changesourceended";
/**
* Fires when the volume has been muted/unmute.
*/
readonly MUTE_CHANGE: "mutechange";
/**
* Fires when the active video track has been changed.
*/
readonly VIDEO_TRACK_CHANGED: "videotrackchanged";
/**
* Fires when the active audio track has been changed.
*/
readonly AUDIO_TRACK_CHANGED: "audiotrackchanged";
/**
* Fires when the active text track has been changed.
*/
readonly TEXT_TRACK_CHANGED: "texttrackchanged";
/**
* Fires when the active image track has been changed.
*/
readonly IMAGE_TRACK_CHANGED: "imagetrackchanged";
/**
* Fires when the text track added to native
*/
readonly TEXT_TRACK_ADDED: "texttrackadded";
/**
* Fires when the active text track cue has changed.
*/
readonly TEXT_CUE_CHANGED: "textcuechanged";
/**
* Fires when the player tracks have been changed.
*/
readonly TRACKS_CHANGED: "trackschanged";
/**
* Fires when the abr mode change from 'auto' to 'manual' or vice versa.
*/
readonly ABR_MODE_CHANGED: "abrmodechanged";
/**
* Fires when the player state has been changed.
*/
readonly PLAYER_STATE_CHANGED: "playerstatechanged";
/**
* Fires when playback start requested.
*/
readonly PLAYBACK_START: "playbackstart";
/**
* Fires on the first 'play' event.
*/
readonly FIRST_PLAY: "firstplay";
/**
* Fires on the first 'playing' event.
*/
readonly FIRST_PLAYING: "firstplaying";
/**
* Fires when the playback (includes postrolls) is ended.
*/
readonly PLAYBACK_ENDED: "playbackended";
/**
* Fires when the player has selected the source to play.
*/
readonly SOURCE_SELECTED: "sourceselected";
/**
* Fires when the text track style has changed.
*/
readonly TEXT_STYLE_CHANGED: "textstylechanged";
/**
* Fired when the adapter recovered from a media error
*/
readonly MEDIA_RECOVERED: "mediarecovered";
/**
* Fired when the vr stereo mode changed
*/
readonly VR_STEREO_MODE_CHANGED: "vrstereomodechanged";
/**
* Fired when the frames drop are exceeds the allowed (configured) threshold
*/
readonly FPS_DROP: "fpsdrop";
/**
* Fired when the a bookmark service returns an error
* This event will be removed once plugins will have a way to expose their event enums
*/
readonly BOOKMARK_ERROR: "bookmarkerror";
/**
* Fired when the a bookmark service returns a concurrency limit error
* This event will be removed once plugins will have a way to expose their event enums
*/
readonly CONCURRENCY_LIMIT: "concurrencylimit";
/**
* Fired when the player container changes it's dimensions
*/
readonly RESIZE: "resize";
/**
* Fired when the timed metadata triggered
*/
readonly TIMED_METADATA: "timedmetadata";
/**
* Fired when the timed metadata triggered
*/
readonly TIMED_METADATA_CHANGE: "timedmetadatachange";
/**
* Fires when new timed metadata added
*/
readonly TIMED_METADATA_ADDED: "timedmetadataadded";
/**
* Fired when a fragment or segment is done loading successfully
*/
readonly FRAG_LOADED: "fragloaded";
/**
* Fired when a manifest is done loading successfully
*/
readonly MANIFEST_LOADED: "manifestloaded";
/**
* Fired when the user interact with the player ui
*/
readonly USER_GESTURE: "usergesture";
/**
* Fired when the drm license is responded from the DRM server
*/
readonly DRM_LICENSE_LOADED: "drmlicenseloaded";
/**
* Fired when the source url switched
*/
readonly SOURCE_URL_SWITCHED: "sourceurlswitched";
/**
* Fired when a new timeline region is parsed and added by the playback engine
*/
readonly TIMELINE_REGION_ADDED: "timelineregionadded";
/**
* Fired when a new timeline region entered
*/
readonly TIMELINE_REGION_ENTER: "timelineregionenter";
/**
* Fired when a new timeline region exited
*/
readonly TIMELINE_REGION_EXIT: "timelineregionexit";
/**
* Fired when playback reaches 25% of the total duration
*/
readonly PLAY_REACHED_25_PERCENT: "playreached25percent";
/**
* Fired when playback reaches 50% of the total duration
*/
readonly PLAY_REACHED_50_PERCENT: "playreached50percent";
/**
* Fired when playback reaches 75% of the total duration
*/
readonly PLAY_REACHED_75_PERCENT: "playreached75percent";
/**
* Fired when playback reaches 90% of the total duration
*/
readonly PLAY_REACHED_90_PERCENT: "playreached90percent";
/**
* Fired when playback reaches 100% of the total duration
*/
readonly PLAY_REACHED_100_PERCENT: "playreached100percent";
/**
* Fired when new thumbnail ks is updated
*/
readonly THUMBNAIL_KS_UPDATED: "thumbnailksupdated";
};
export declare type DeferredPromise = {
resolve: (value?: any | PromiseLike<any>) => void;
reject: (reason?: any) => void;
catch: (param: () => any) => void;
then(param: () => void): any;
};
declare const _Dom: {
/**
* Adds class name to an element
* @param {Element} element - an HTML element
* @param {string} className - a class name
* @returns {void}
*/
addClassName(element: HTMLElement, className: string): void;
/**
* Removes class name from an element
* @param {Element} element - an HTML element
* @param {string} className - a class name
* @returns {void}
*/
removeClassName(element: HTMLElement, className: string): void;
/**
* Checks if an element has a class name
* @param {Element} element - an HTML element
* @param {string} className - a class name
* @returns {boolean} - weather an element contains a class name
*/
hasClassName(element: HTMLElement, className: string): boolean;
/**
* Add element attribute
* @param {Element} element - an HTML element
* @param {string} name - attribute name
* @param {string} value - attribute value
* @returns {void}
*/
setAttribute(element: HTMLElement, name: string, value: string): void;
/**
* Remove element attribute
* @param {Element} element - an HTML element
* @param {string} name - attribute name
* @returns {void}
*/
removeAttribute(element: HTMLElement, name: string): void;
/**
* Set element style
* @param {Element} element - an HTML element
* @param {string} name - style name
* @param {string} value - style value
* @returns {void}
*/
setStyle(element: HTMLElement, name: string, value: string): void;
/**
* Adds a node to the end of the list of children of a specified parent node.
* @param {Element} parent - The parent node.
* @param {Element} child - The child node.
* @returns {void}
*/
appendChild(parent?: HTMLElement, child?: HTMLElement): void;
/**
* Removes an element from his parent node.
* @param {Element} parent - The parent node.
* @param {Element} child - The child node.
* @returns {void}
*/
removeChild(parent?: Node | null, child?: HTMLElement): void;
/**
* Prepend HTML element
* @param {HTMLElement} child - the child to prepend
* @param {HTMLElement} parent - the parent to preprend to
* @returns {void}
*/
prependTo(child: HTMLElement, parent: HTMLElement): void;
/**
* Returns a reference to the element by its ID.
* @param {string} id - The desired id.
* @returns {Element} - The element with the desired id.
*/
getElementById(id: string): any;
/**
* Returns a live HTMLCollection of elements with the given tag name.
* @param {string} tagName - The desired tag name.
* @returns {Element} - The elements with the desired tag name.
*/
getElementsByTagName(tagName: string): any;
/**
* Creates the HTML element specified by tagName.
* @param {string} tagName - The tag name.
* @returns {Element} - The element just created.
*/
createElement(tagName: string): any;
/**
* Loads an external style sheet asynchronously.
* @param {string} url - The css url to load.
* @return {Promise} - The loading promise.
* @public
*/
loadStyleSheetAsync(url: string): Promise<HTMLLinkElement>;
/**
* Loads script asynchronously.
* @param {string} url - The url to load.
* @return {Promise} - The loading promise.
* @public
*/
loadScriptAsync(url: string): Promise<any>;
/**
* Returns the first element that matches a specified CSS selector(s) in the document.
* @param {string} selector - One or more CSS selectors to match the element.
* @returns {Element} - The first element that matches a specified CSS selector(s) in the document.
*/
getElementBySelector(selector: string): any;
/**
* Inserts a node as a child, right before an existing child.
* @param {HTMLElement} parent - The parent node object.
* @param {HTMLElement} newChild - The node object to insert.
* @param {?HTMLElement} existingChild - The child node to insert the new node before. If set to null, the insertBefore method will insert the newChild at the end.
* @returns {Element} - The first element that matches a specified CSS selector(s) in the document.
*/
insertBefore(parent: HTMLElement, newChild: HTMLElement, existingChild?: HTMLElement | null): HTMLElement | null;
};
export declare const DrmScheme: {
WIDEVINE: string;
PLAYREADY: string;
FAIRPLAY: string;
};
export declare class EngineDecoratorProvider implements IEngineDecoratorProvider {
private _name;
private _getEngineDecorator;
constructor(plugin: IEngineDecoratorProvider);
getEngineDecorator(engine: IEngine, dispatchEventHandler: (event: FakeEvent) => void): IEngineDecorator;
getName(): string;
}
/**
* Engine Provider
* @classdesc
*/
declare class EngineProvider {
/**
* The logger of the Engine provider.
* @member {any} _logger
* @static
* @private
*/
private static _logger;
/**
* The Engine registry.
* @member {Object} _engineProviders
* @static
* @private
*/
private static _engineProviders;
/**
* Add an engine to the registry.
* @function register
* @param {string} id - The engine id.
* @param {IEngineStatic} engine - The engine to register.
* @static
* @returns {void}
*/
static register(id: string, engine: IEngineStatic): void;
/**
* Remove an engine from the registry.
* @function unRegister
* @param {string} id - The engine id.
* @static
* @returns {void}
*/
static unRegister(id: string): void;
/**
* Get the appropriate Engines.
* @function getEngines
* @returns {Array<IEngineStatic>} - The Array of engines, or null if such doesn't exists.
* @static
*/
static getEngines(): Array<IEngineStatic>;
/**
* Destroys and clear the registered engines
* @static
* @returns {void}
*/
static destroy(): void;
}
export declare const EngineType: {
readonly HTML5: "html5";
readonly FLASH: "flash";
readonly SILVERLIGHT: "silverlight";
readonly CAST: "cast";
readonly YOUTUBE: "youtube";
readonly IMAGE: "image";
readonly DOCUMENT: "document";
};
export declare const Env: IEnv;
/**
* @classdesc This is a description of the error class.
*/
declare class Error_2 {
severity: number;
category: number;
code: number;
data: any;
errorDetails: any;
/**
* @enum {number}
*/
static Severity: SeverityType;
/**
* @enum {number}
*/
static Category: CategoryType;
/**
* @enum {number}
*/
static Code: CodeType;
private static _logger;
/**
* @constructor
* @param {number} severity - error's severity
* @param {number} category - error's category.
* @param {number} code - error's code.
* @param {any} data - additional data for the error.
* @param {any} errorDetails - error details including title and message - optional.
*/
constructor(severity: number, category: number, code: number, data?: any, errorDetails?: any);
}
export { Error_2 as Error }
/**
* These are the listener types defined in the closure extern for EventTarget.
* @typedef {EventListener|function(!Event):(boolean|undefined)}
*/
declare function EventListener_2(event: FakeEvent): boolean | void;
/**
* Creates a new EventManager. An EventManager maintains a collection of "event
* bindings" between event targets and event listeners.
*
* @struct
* @constructor
* @implements {IDestroyable}
*/
export declare class EventManager {
private _bindingMap;
constructor();
/**
* Detaches all event listeners.
* @override
*/
destroy(): Promise<void>;
/**
* Attaches an event listener to an event target for only one time.
* @param {EventTarget} target - The event target.
* @param {string} type - The event type.
* @param {ListenerType} listener - The event listener.
* @param {?Object} options - The event options.
* @returns {void}
*/
listenOnce(target: EventTarget | FakeEventTarget, type: string, listener: ListenerType, options?: any): void;
/**
* Attaches an event listener to an event target.
* @param {EventTarget} target The event target.
* @param {string} type The event type.
* @param {ListenerType} listener The event listener.
* @param {?Object} options The event options.
* @returns {void}
*/
listen(target: EventTarget | FakeEventTarget, type: string, listener: ListenerType, options?: any): void;
/**
* Detaches an event listener from an event target.
* @param {EventTarget} target The event target.
* @param {string} type The event type.
* @param {ListenerType} [listener] The event listener to detach. If no given, detaches all event listeners of the target and type.
* @returns {void}
*/
unlisten(target: any, type: string, listener?: ListenerType): void;
/**
* Detaches all event listeners from all targets.
* @returns {void}
*/
removeAll(): void;
}
export declare const EventType: PKEventTypes;
/**
* Create an Event work-alike object based on the dictionary.
* The event should contain all of the same properties from the dict.
* @param {string} type -
* @param {Object=} opt_dict -
* @constructor
* @extends {Event}
*/
export declare class FakeEvent {
/** @const {boolean} */
bubbles: boolean;
/** @const {boolean} */
cancelable: boolean;
/** @const {boolean} */
defaultPrevented: boolean;
/**
* According to MDN, Chrome uses high-res timers instead of epoch time.
* Follow suit so that timeStamps on FakeEvents use the same base as
* on native Events.
* @const {number}
* @see https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp
*/
timeStamp: number | Date;
/** @const {string} */
type: string;
/** @const {boolean} */
isTrusted: boolean;
/** @type {EventTarget} */
currentTarget: any;
/** @type {EventTarget} */
target: any;
/**
* Non-standard property read by FakeEventTarget to stop processing listeners.
* @type {boolean}
*/
stopped: boolean;
payload: any;
constructor(type: string, payload?: any);
/**
* Does nothing, since FakeEvents have no default. Provided for compatibility
* with native Events.
* @override
*/
preventDefault(): void;
/**
* Stops processing event listeners for this event. Provided for compatibility
* with native Events.
* @override
*/
stopImmediatePropagation(): void;
/**
* Does nothing, since FakeEvents do not bubble. Provided for compatibility
* with native Events.
* @override
*/
stopPropagation(): void;
}
/**
* 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
* @export
*/
export declare class FakeEventTarget {
private _listeners;
private readonly dispatchTarget;
private __logger;
constructor();
/**
* Add an event listener to this object.
*
* @param {string} type The event type to listen for.
* @param {FakeEventTarget.EventListener} listener The callback or
* listener object to invoke.
* @param {boolean=} opt_capturing Ignored. FakeEventTargets do not have
* parents, so events neither capture nor bubble.
* @override
* @export
*/
addEventListener(type: string, listener: typeof EventListener_2): void;
/**
* Remove an event listener from this object.
*
* @param {string} type The event type for which you wish to remove a listener.
* @param {FakeEventTarget.EventListener} listener The callback or
* listener object to remove.
* @param {boolean=} opt_capturing Ignored. FakeEventTargets do not have
* parents, so events neither capture nor bubble.
* @override
* @export
*/
removeEventListener(type: string, listener: typeof EventListener_2): void;
/**
* 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
* @export
*/
dispatchEvent(event: FakeEvent): boolean;
}
/**
* Filter the video tracks which not in the range
* @function filterVideoTracksByRestriction
* @param {Array<PKVideoTrack>} videoTracks - The tracks to filter
* @param {PKABRRestrictionObject} restriction - The restriction
* @returns {Array<PKVideoTrack>} - The relevant video tracks after restrictions.
*/
export declare function filterTracksByRestriction(videoTracks: VideoTrack[], restriction: PKABRRestrictionObject): VideoTrack[];
export declare type FontAlignmentOptions = 'default' | 'left' | 'center' | 'right';
export declare type FontScaleOptions = -1 | 0 | 2;
export declare type FontSizeOptions = '100%' | '112.5%' | '125%';
declare const _Generator: {
/**
* Generates unique id.
* @param {number} length - The length of the id.
* @returns {string} - The generated id.
*/
uniqueId: (length?: number) => string;
/**
* Generates GUID.
* @return {string} - GUID
* @private
*/
guid: () => string;
};
export declare const getCapabilities: typeof Player.getCapabilities;
/**
* get a logger
* @param {?string} name - the logger name
* @returns {Object} - the logger class
*/
export declare function getLogger(name?: string): ILogger;
/**
* get the log level
* @param {?string} name - the logger name
* @returns {PKLogLevelObject} - the log level
*/
export declare function getLogLevel(name?: string): ILogLevel;
/**
* Returns the native language name for a given ISO language code using Intl.DisplayNames.
* Falls back to the provided fallback string if the code is absent or the API throws.
* @param {string | undefined | null} langCode - ISO 639-1/2 language code (e.g. "es", "ja")
* @param {string} fallback - Value to return when the code cannot be resolved
* @returns {string} - Native language name or fallback
*/
export declare function getNativeLanguageName(langCode: string | undefined | null, fallback: string): string;
declare const getSubtitleStyleSheet: (playerId: string) => CSSStyleSheet;
export declare const Html5EventType: {
/**
* Fires when the loading of an audio/video is aborted
*/
readonly ABORT: "abort";
/**
* Fires when the browser can start playing the audio/video
*/
readonly CAN_PLAY: "canplay";
/**
* Fires when the browser can play through the audio/video without stopping for buffering
*/
readonly CAN_PLAY_THROUGH: "canplaythrough";
/**
* Fires when the duration of the audio/video is changed
*/
readonly DURATION_CHANGE: "durationchange";
/**
* Fires when the current playlist is empty
*/
readonly EMPTIED: "emptied";
/**
* Fires when the current playlist is ended
*/
readonly ENDED: "ended";
/**
* Fires when an error occurred during the loading of an audio/video
*/
readonly ERROR: "error";
/**
* Fires when the browser has loaded the current frame of the audio/video
*/
readonly LOADED_DATA: "loadeddata";
/**
* Fires when the browser has loaded meta data for the audio/video
*/
readonly LOADED_METADATA: "loadedmetadata";
/**
* Fires when the browser starts looking for the audio/video
*/
readonly LOAD_START: "loadstart";
/**
* Fires when the audio/video has been paused
*/
readonly PAUSE: "pause";
/**
* Fires when the audio/video has been started or is no longer paused
*/
readonly PLAY: "play";
/**
* Fires when the audio/video is playing after having been paused or stopped for buffering
*/
readonly PLAYING: "playing";
/**
* Fires when the browser is downloading the audio/video
*/
readonly PROGRESS: "progress";
/**
* Fires when the playing speed of the audio/video is changed
*/
readonly RATE_CHANGE: "ratechange";
/**
* Fires when the user is finished moving/skipping to a new position in the audio/video
*/
readonly SEEKED: "seeked";
/**
* Fires when the user starts moving/skipping to a new position in the audio/video
*/
readonly SEEKING: "seeking";
/**
* Fires when the browser is trying to get media data, but data is not available
*/
readonly STALLED: "stalled";
/**
* Fires when the browser is intentionally not getting media data
*/
readonly SUSPEND: "suspend";
/**
* Fires when the current playback position has changed
*/
readonly TIME_UPDATE: "timeupdate";
/**
* Fires when the volume has been changed
*/
readonly VOLUME_CHANGE: "volumechange";
/**
* Fires when the video stops because it needs to buffer the next frame
*/
readonly WAITING: "waiting";
/**
* Fires when the engine enters picture in picture
*/
readonly ENTER_PICTURE_IN_PICTURE: "enterpictureinpicture";
/**
* Fires when the engine exits picture in picture
*/
readonly LEAVE_PICTURE_IN_PICTURE: "leavepictureinpicture";
/**
* Fires when the engine changes presentation mode on safari webkitpresentationmodechanged
*/
readonly PRESENTATION_MODE_CHANGED: "webkitpresentationmodechanged";
};
declare const _Http: {
protocol: string;
execute: (url: string, params: any, method?: string, headers?: Map<string, string>, timeout?: number, ontimeout?: ((...args: any[]) => any) | undefined) => Promise<any>;
jsonp: typeof jsonp;
convertHeadersToDictionary: (headerRow: string) => {
[header: string]: string;
};
};
declare interface IBrowser {
/**
* Possible values :
* Amaya, Android Browser, Arora, Avant, Baidu, Blazer, Bolt, Camino, Chimera, Chrome,
* Chromium, Comodo Dragon, Conkeror, Dillo, Dolphin, Doris, Edge, Epiphany, Fennec,
* Firebird, Firefox, Flock, GoBrowser, iCab, ICE Browser, IceApe, IceCat, IceDragon,
* Iceweasel, IE [Mobile], Iron, Jasmine, K-Meleon, Konqueror, Kindle, Links,
* Lunascape, Lynx, Maemo, Maxthon, Midori, Minimo, MIUI Browser, [Mobile] Safari,
* Mosaic, Mozilla, Netfront, Netscape, NetSurf, Nokia, OmniWeb, Opera [Mini/Mobi/Tablet],
* Phoenix, Polaris, QQBrowser, RockMelt, Silk, Skyfire, SeaMonkey, SlimBrowser, Swiftfox,
* Tizen, UCBrowser, Vivaldi, w3m, Yandex
*/
name: string | undefined;
/**
* Determined dynamically
*/
version: string | undefined;
/**
* Determined dynamically
* @deprecated
*/
major: string | undefined;
}
export declare interface ICapability {
runCapability(): void;
getCapability(): Promise<CapabilityResult>;
setCapabilities(capabilities: {
[name: string]: any;
}): void;
}
declare interface ICPU {
/**
* Possible architecture:
* 68k, amd64, arm, arm64, avr, ia32, ia64, irix, irix64, mips, mips64, pa-risc,
* ppc, sparc, sparc64
*/
architecture: string | undefined;
}
declare interface IDevice {
/**
* Determined dynamically
*/
model: string | undefined;
/**
* Possible type:
* console, mobile, tablet, smarttv, wearable, embedded
*/
type: string | undefined;
/**
* Possible vendor:
* Acer, Alcatel, Amazon, Apple, Archos, Asus, BenQ, BlackBerry, Dell, GeeksPhone,
* Google, HP, HTC, Huawei, Jolla, Lenovo, LG, Meizu, Microsoft, Motorola, Nexian,
* Nintendo, Nokia, Nvidia, Ouya, Palm, Panasonic, Polytron, RIM, Samsung, Sharp,
* Siemens, Sony-Ericsson, Sprint, Xbox, ZTE
*/
vendor: string | undefined;
}
export declare interface IDrmProtocol {
isConfigured(drmData: Array<PKDrmDataObject>, drmConfig: PKDrmConfigObject): boolean;
canPlayDrm(drmData: Array<PKDrmDataObject>): boolean;
setDrmPlayback(...any: any[]): void;
}
export declare interface IEngine extends FakeEventTarget {
restore(source: PKMediaSourceObject, config: Object): void;
destroy(): void;
attach(): void;
detach(): void;
play(): Promise<any> | undefined;
pause(): void;
load(startTime?: number): Promise<{
tracks: Track[];
}>;
reset(): void;
selectVideoTrack(videoTrack: VideoTrack): void;
selectAudioTrack(audioTrack: AudioTrack): void;
selectTextTrack(textTrack: TextTrack_2): void;
selectImageTrack(imageTrack: ImageTrack): void;
isPictureInPictureSupported(): boolean;
enterPictureInPicture(): void;
exitPictureInPicture(): void;
hideTextTrack(): void;
enableAdaptiveBitrate(): void;
isAdaptiveBitrateEnabled(): boolean;
applyABRRestriction(restrictions: PKABRRestrictionObject): void;
seekToLiveEdge(): void;
getStartTimeOfDvrWindow(): number;
isLive(): boolean;
getVideoElement(): HTMLVideoElement;
resetAllCues(): void;
attachMediaSource(): void;
detachMediaSource(): void;
getThumbnail(time: number): ThumbnailInfo | null;
isOnLiveEdge(): boolean;
addTextTrack(kind: TextTrackKind, label?: string, language?: string): TextTrack | undefined;
getNativeTextTracks(): TextTrack[];
getDrmInfo(): PKDrmDataObject | null;
setCachedUrls(cachedUrls: string[]): any;
shouldAddTextTrack?(): void;
id: string;
currentTime: number;
duration: number;
liveDuration: number;
volume: number;
paused: boolean;
seeking: boolean;
played: TimeRanges;
buffered: TimeRanges;
videoHeight: number;
videoWidth: number;
muted: boolean;
defaultMuted: boolean;
src: string;
poster: string;
preload: 'none' | 'metadata' | 'auto' | '';
autoplay: boolean;
controls: boolean;
loop: boolean;
error: MediaError | null;
seekable: TimeRanges;
ended: boolean;
playbackRate: number;
playbackRates: Array<number>;
defaultPlaybackRate: number;
isInPictureInPicture: boolean;
networkState: number;
readyState: number;
playsinline: boolean;
crossOrigin: string | null;
targetBuffer: number;
availableBuffer: number;
mediaSourceAdapter: IMediaSourceAdapter | null;
}
declare interface IEngine_2 {
/**
* Possible name:
* Amaya, EdgeHTML, Gecko, iCab, KHTML, Links, Lynx, NetFront, NetSurf, Presto,
* Tasman, Trident, w3m, WebKit
*/
name: string | undefined;
/**
* Determined dynamically
*/
version: string | undefined;
}
export declare interface IEngineDecorator {
active: boolean;
dispatchEvent(event: FakeEvent): boolean;
restore?: (source: PKMediaSourceObject, config: any) => void;
reset?: () => void;
destroy?: () => void;
attach?: () => void;
detach?: () => void;
getVideoElement?: () => HTMLVideoElement;
selectVideoTrack?: (videoTrack: VideoTrack) => void;
selectAudioTrack?: (audioTrack: AudioTrack) => void;
selectTextTrack?: (textTrack: TextTrack_2) => void;
hideTextTrack?: () => void;
enableAdaptiveBitrate?: () => void;
isAdaptiveBitrateEnabled?: () => boolean;
seekToLiveEdge?: () => void;
getStartTimeOfDvrWindow?: () => number;
isLive?: () => boolean;
play?: () => void;
pause?: () => void;
load?: (startTime?: number) => Promise<any>;
enterPictureInPicture?: () => void;
exitPictureInPicture?: () => void;
isPictureInPictureSupported?: () => boolean;
resetAllCues?: () => void;
attachMediaSource?: () => void;
detachMediaSource?: () => void;
id?: string;
src?: string;
currentTime?: number;
duration?: number;
volume?: number;
paused?: boolean;
seeking?: boolean;
seekable?: TimeRanges;
played?: TimeRanges;
buffered?: TimeRanges;
muted?: boolean;
defaultMuted?: boolean;
poster?: string;
preload?: string;
autoplay?: boolean;
loop?: boolean;
controls?: boolean;
playbackRates?: Array<number>;
playbackRate?: number;
defaultPlaybackRate?: number;
ended?: boolean;
error?: MediaError;
networkState?: number;
readyState?: number;
videoHeight?: number;
videoWidth?: number;
playsinline?: boolean;
crossOrigin?: string;
isInPictureInPicture?: boolean;
targetBuffer?: number;
availableBuffer?: number;
}
export declare interface IEngineDecoratorProvider {
getEngineDecorator(engine: IEngine, dispatchEventHandler: Function): IEngineDecorator;
getName(): string;
}
export declare interface IEngineStatic {
id: string;
createEngine(source: PKMediaSourceObject, config: Object, playerId: string): IEngine;
canPlaySource(source: PKMediaSourceObject, preferNative: boolean, drmConfig: PKDrmConfigObject): boolean;
runCapabilities(): void;
getCapabilities(): Promise<any>;
setCapabilities(capabilities: {
[name: string]: any;
}): void;
prepareVideoElement(playerId: string): void;
isSupported(): boolean;
}
declare interface IEnv extends IResult {
isConsole: boolean;
isSmartTV: boolean;
isMobile: boolean;
isTablet: boolean;
isWearable: boolean;
isEmbedded: boolean;
isIPadOS: boolean;
isSafari: boolean;
isIOS: boolean;
isMacOS: boolean;
isChrome: boolean;
isEdge: boolean;
isFirefox: boolean;
}
export declare type ImageSourceOptions = {
thumbnailAPIParams: {
[parmaName: string]: string;
};
};
export declare class ImageTrack extends Track {
private _url;
private _width;
private _height;
private _duration;
private _rows;
private _cols;
private _customData;
constructor(settings: {
id: string;
active: boolean;
index: number;
url: string;
width: number;
height: number;
duration: number;
rows: number;
cols: number;
customData: any;
});
get url(): string;
get width(): number;
get height(): number;
get duration(): number;
get rows(): number;
get cols(): number;
get customData(): any;
get sliceWidth(): number;
get sliceHeight(): number;
}
export declare interface IMediaSourceAdapter extends FakeEventTarget {
src: string;
liveDuration: number;
capabilities: PKMediaSourceCapabilities;
targetBuffer: number;
load(startTime?: number): Promise<{
tracks: Track[];
}>;
handleMediaError(error?: MediaError): boolean;
destroy(): Promise<any>;
selectVideoTrack(videoTrack: VideoTrack): void;
selectAudioTrack(audioTrack: AudioTrack): void;
selectTextTrack(textTrack: TextTrack_2): void;
selectImageTrack(imageTrack: ImageTrack): void;
hideTextTrack(): void;
enableAdaptiveBitrate(): void;
isAdaptiveBitrateEnabled(): boolean;
seekToLiveEdge(): void;
isLive(): boolean;
isOnLiveEdge(): boolean;
getStartTimeOfDvrWindow(): number;
setMaxBitrate(bitrate: number): void;
attachMediaSource(): void;
detachMediaSource(): void;
getSegmentDuration(): number;
disableNativeTextTracks(): void;
getThumbnail(time: number): ThumbnailInfo | null;
getDrmInfo(): PKDrmDataObject | null;
applyABRRestriction(restriction: PKABRRestrictionObject): void;
applyTextTrackStyles(sheet: CSSStyleSheet, styles: TextStyle, containerId: string, engineClassName?: string): void;
setCachedUrls(cachedUrls: string[]): any;
}
export declare interface IMediaSourceAdapterStatic {
id: string;
isSupported(): boolean;
isMSESupported(): boolean;
canPlayType(mimeType: string): boolean;
canPlayDrm(drmData: Array<Object>, drmConfig: PKDrmConfigObject): boolean;
createAdapter(videoElement: HTMLVideoElement, source: PKMediaSourceObject, config: Object): IMediaSourceAdapter;
}
declare interface IOS {
/**
* Possible 'os.name'
* AIX, Amiga OS, Android, Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS, Contiki,
* Fedora, Firefox OS, FreeBSD, Debian, DragonFly, Gentoo, GNU, Haiku, Hurd, iOS,
* Joli, Linpus, Linux, Mac OS, Mageia, Mandriva, MeeGo, Minix, Mint, Morph OS, NetBSD,
* Nintendo, OpenBSD, OpenVMS, OS/2, Palm, PCLinuxOS, Plan9, Playstation, QNX, RedHat,
* RIM Tablet OS, RISC OS, Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen,
* Ubuntu, UNIX, VectorLinux, WebOS, Windows [Phone/Mobile], Zenwalk
*/
name: string | undefined;
/**
* Determined dynamically
*/
version: string | undefined;
}
declare interface IResult {
ua: string;
browser: IBrowser;
device: IDevice;
engine: IEngine_2;
os: IOS;
cpu: ICPU;
}
/**
* JSONP utility.
* @param {string} url - The url of the request.
* @param {string} callback - Callback function to be called when the request returns.
* @param {Object} options - Object contains configuration (currently only timeout).
* @returns {Promise<*>} - A promise with the callback output.
*/
declare function jsonp(url: string, callback: (...args: any[]) => any, options: {
timeout: number;
}): Promise<any>;
/**
* @typedef {function(!Event)}
*/
declare type ListenerType = EventListener | ((event: FakeEvent) => any);
/**
* @param {Object} config - The configuration of the player
* @returns {Player} - The player instance
*/
declare function loadPlayer(config: any): Player;
export default loadPl