### Load and Control Video Stream Source: https://hlsjs.video-dev.org/api-docs/index Manages the loading and playback of video streams. Allows setting the source URL, starting and stopping the stream, and controlling buffering. ```javascript loadSource(url: string): void; startLoad(startPosition?: number, skipSeekToStartPosition?: boolean): void; stopLoad(): void; pauseBuffering(): void; resumeBuffering(): void; ``` -------------------------------- ### Hls.js Player Properties Source: https://hlsjs.video-dev.org/api-docs/index This section details the various read-only and writable properties of the hls.js player instance, which can be accessed to get or set player state and configuration. ```APIDOC ## Hls.js Player Properties Overview This documentation provides details on the properties available on an hls.js player instance. These properties allow for monitoring and, in some cases, controlling the player's behavior. ### Properties: - **abrEwmaDefaultEstimate** (`readonly`, `number`): Default estimate for ABR. - **allAudioTracks** (`readonly`, `MediaPlaylist[]`): Get the complete list of audio tracks across all media groups. - **allSubtitleTracks** (`readonly`, `MediaPlaylist[]`): Get the complete list of subtitle tracks across all media groups. - **audioTrack** (`number`): Index of the selected audio track. - **audioTracks** (`readonly`, `MediaPlaylist[]`): Get the list of selectable audio tracks. - **autoLevelCapping** (`number`): Capping/max level value for automatic level selection. - **autoLevelEnabled** (`readonly`, `boolean`): True when automatic level selection is enabled. - **bandwidthEstimate** (`number`): Current bandwidth estimate in bits per second, or `NaN`. - **bufferedToEnd** (`readonly`, `boolean`): Returns true when all SourceBuffers are buffered to the end. - **bufferingEnabled** (`readonly`, `boolean`): Returns the state of fragment loading. - **capLevelToPlayerSize** (`boolean`): Whether level capping is enabled. - **config** (`readonly`, `HlsConfig`): The runtime configuration used by the player. - **currentLevel** (`number`): Index of the quality level currently being played. - **drift** (`readonly`, `number`): The rate at which the edge of the current live playlist is advancing. - **firstAutoLevel** (`readonly`, `number`): First automatically selected level. - **firstLevel** (`number`): Index of the first level referenced in the manifest, used as a fallback. - **forceStartLoad** (`readonly`, `boolean`): True if `startLoad` was called before `MANIFEST_PARSED`. - **hasEnoughToStart** (`readonly`, `boolean`): Whether enough has been buffered to seek to the start position. - **inFlightFragments** (`readonly`, `InFlightFragments`): Information about fragments currently being loaded. - **interstitialsManager** (`readonly`, `InterstitialsManager`): Manager for interstitials. - **latency** (`readonly`, `number`): Estimated position of the live edge in seconds. - **latestLevelDetails** (`readonly`, `LevelDetails`): Details of the latest loaded level. - **levels** (`readonly`, `Level[]`): Array of available quality levels. - **liveSyncPosition** (`readonly`, `number`): Position in seconds of the live sync point. - **loadingEnabled** (`readonly`, `boolean`): Returns whether loading is active. - **loadLevel** (`number`): Quality level of the currently or last loaded segment. - **loadLevelObj** (`readonly`, `Level`): The object representing the currently loaded level. - **logger** (`readonly`, `ILogger`): The logger functions used by the player instance. - **lowLatencyMode** (`boolean`): Get or set the mode for Low-Latency HLS loading. - **mainForwardBufferInfo** (`readonly`, `BufferInfo`): Buffer information for the main forward stream. - **manualLevel** (`readonly`, `number`): Level set manually, if any. - **maxAutoLevel** (`readonly`, `number`): Maximum level selectable in auto mode. - **maxBufferLength** (`readonly`, `number`): Maximum buffer length. - **maxHdcpLevel** (`number`): Maximum HDCP level. - **maxLatency** (`readonly`, `number`): Maximum distance from the edge before seeking forward. - **media** (`readonly`, `HTMLMediaElement`): The HTML media element associated with the player. - **minAutoLevel** (`readonly`, `number`): Minimum level selectable in auto mode. - **nextAutoLevel** (`number`): Next automatically selected quality level. - **nextLevel** (`number`): Index of the next quality level scheduled for loading. - **nextLoadLevel** (`number`): The quality level next to be loaded. - **pathwayPriority** (`string[]`): ContentSteering pathway priority getter/setter. - **pathways** (`readonly`, `string[]`): ContentSteering pathways getter. - **playingDate** (`readonly`, `Date`): The datetime value relative to `media.currentTime` for the active level Program Date Time. - **sessionId** (`readonly`, `string`): The session ID of the player instance. ### Static Properties: - **DefaultConfig** (`static`, `HlsConfig`): Get the default configuration applied to new instances. - **ErrorDetails** (`static`, `typeof ErrorDetails`): Error details. - **ErrorTypes** (`static`, `typeof ErrorTypes`): Error types. - **Events** (`static`, `typeof Events`): Available HLS events. - **MetadataSchema** (`static`, `typeof MetadataSchema`): Metadata schema. ``` -------------------------------- ### Get MediaSource Global Source: https://hlsjs.video-dev.org/api-docs/index Retrieves the global MediaSource object used for MSE playback, which can be ManagedMediaSource, MediaSource, or WebKitMediaSource. ```javascript static getMediaSource(): MediaSource | ManagedMediaSource | WebKitMediaSource; ``` -------------------------------- ### Get Media Decoding Information Source: https://hlsjs.video-dev.org/api-docs/index Retrieves media capabilities decoding information for a given variant or rendition, aiding in playback compatibility checks. ```javascript getMediaDecodingInfo(level: number, audioTracks: any[]): MediaDecodingInfo; ``` -------------------------------- ### FragmentTracker.removeFragmentsInRange() Method Signature Source: https://hlsjs.video-dev.org/api-docs/hls.js.fragmenttracker This is the TypeScript signature for the removeFragmentsInRange method. It outlines the parameters: start, end, playlistType, and optional booleans withGapOnly and unbufferedOnly. The method returns void. ```typescript removeFragmentsInRange(start: number, end: number, playlistType: PlaylistLevelType, withGapOnly?: boolean, unbufferedOnly?: boolean): void; ``` -------------------------------- ### Hls Constructor Source: https://hlsjs.video-dev.org/api-docs/index Details the constructor for the Hls class, which takes a user-defined configuration object. This constructor initializes an HLS client designed to work with a single HTMLMediaElement for video playback. ```typescript constructor(userConfig) ``` -------------------------------- ### Hls.js Methods Source: https://hlsjs.video-dev.org/api-docs/index Core methods for controlling HLS playback, including attaching media, loading sources, and managing playback state. ```APIDOC ## Hls.js Methods ### attachMedia * **Description**: Attaches Hls.js to a media element. * **Method**: `attachMedia` * **Parameters**: `data` (media element) ### createController * **Description**: Creates a controller instance. * **Method**: `createController` * **Parameters**: `ControllerClass`, `components` ### destroy * **Description**: Disposes of the hls.js instance. * **Method**: `destroy` ### detachMedia * **Description**: Detaches Hls.js from the media element. * **Method**: `detachMedia` ### emit * **Description**: Emits an event. * **Method**: `emit` * **Parameters**: `event`, `name`, `eventObject` ### getMediaDecodingInfo * **Description**: Returns mediaCapabilities.decodingInfo for a variant/rendition. * **Method**: `getMediaDecodingInfo` * **Parameters**: `level`, `audioTracks` ### getMediaSource * **Description**: Get the MediaSource global used for MSE playback. * **Method**: `getMediaSource` * **Access**: Static ### isMSESupported * **Description**: Check if the required MediaSource Extensions are available. * **Method**: `isMSESupported` * **Access**: Static ### isSupported * **Description**: Check if MediaSource Extensions are available and isTypeSupported checks pass for any baseline codecs. * **Method**: `isSupported` * **Access**: Static ### listenerCount * **Description**: Returns the number of listeners for a given event. * **Method**: `listenerCount` * **Parameters**: `event` ### listeners * **Description**: Returns a list of listeners for a given event. * **Method**: `listeners` * **Parameters**: `event` ### loadSource * **Description**: Set the source URL. Can be relative or absolute. * **Method**: `loadSource` * **Parameters**: `url` (string) ### off * **Description**: Removes an event listener. * **Method**: `off` * **Parameters**: `event`, `listener`, `context`, `once` ### on * **Description**: Adds an event listener. * **Method**: `on` * **Parameters**: `event`, `listener`, `context` ### once * **Description**: Adds an event listener that will be called only once. * **Method**: `once` * **Parameters**: `event`, `listener`, `context` ### pauseBuffering * **Description**: Prevents stream controller from loading new segments until `resumeBuffering` is called. * **Method**: `pauseBuffering` ### recoverMediaError * **Description**: Recovers from a media error by detaching and re-attaching the media element. * **Method**: `recoverMediaError` ### removeAllListeners * **Description**: Removes all listeners for a given event. * **Method**: `removeAllListeners` * **Parameters**: `event` ### removeLevel * **Description**: Removes a level from the manifest. * **Method**: `removeLevel` * **Parameters**: `levelIndex` (number) ### resumeBuffering * **Description**: Resumes stream controller segment loading after `pauseBuffering` has been called. * **Method**: `resumeBuffering` ### setAudioOption * **Description**: Selects the best matching audio track. * **Method**: `setAudioOption` * **Parameters**: `audioOption` * **Returns**: Selected track or null. ### setSubtitleOption * **Description**: Selects the best matching subtitle track. * **Method**: `setSubtitleOption` * **Parameters**: `subtitleOption` * **Returns**: Selected track or null. ### startLoad * **Description**: Starts loading data from the stream source. * **Method**: `startLoad` * **Parameters**: `startPosition` (optional), `skipSeekToStartPosition` (optional) ### stopLoad * **Description**: Stops loading of any stream data. * **Method**: `stopLoad` ### swapAudioCodec * **Description**: Swaps through possible audio codecs in the stream. * **Method**: `swapAudioCodec` ### transferMedia * **Description**: Detaches HTMLMediaElement, MediaSource, and SourceBuffers without reset. * **Method**: `transferMedia` ### trigger * **Description**: Triggers an event. * **Method**: `trigger` * **Parameters**: `event`, `eventObject` ``` -------------------------------- ### Access Player Configuration and Version Source: https://hlsjs.video-dev.org/api-docs/index Provides access to the player's configuration object and the version of the hls.js library. ```javascript userConfig: Partial; static version: string; ``` -------------------------------- ### Hls Class Constructor Source: https://hlsjs.video-dev.org/api-docs/index This section details the constructor for the Hls class, which is used to create a new HLS player instance attached to an HTMLMediaElement. ```APIDOC ## Hls Constructor ### Description Creates an instance of an HLS client that can attach to exactly one `HTMLMediaElement`. ### Method constructor ### Parameters #### Request Body - **userConfig** (object) - Optional - User-defined configuration object to customize HLS.js behavior. ### Request Example ```json { "userConfig": { "autoStartLoad": true, "debug": false } } ``` ### Response #### Success Response (200) - **hlsInstance** (object) - An instance of the Hls class representing the HLS player. #### Response Example ```json { "hlsInstance": "[Hls instance object]" } ``` ``` -------------------------------- ### Handle Subtitle and Audio Tracks Source: https://hlsjs.video-dev.org/api-docs/index Provides functionality to manage subtitle and audio tracks, including selecting preferred tracks and swapping audio codecs. ```javascript subtitleDisplay: boolean; subtitleTrack: number; subtitleTracks: MediaPlaylist[]; setSubtitleOption(subtitleOption: any): MediaPlaylist | null; setAudioOption(audioOption: any): MediaPlaylist | null; swapAudioCodec(): void; ``` -------------------------------- ### Check Media Source Extensions Support Source: https://hlsjs.video-dev.org/api-docs/index Checks if MediaSource Extensions (MSE) are available and if baseline codecs are supported. This is crucial for MSE playback. ```javascript static isSupported(): boolean; static isMSESupported(): boolean; ``` -------------------------------- ### Hls.js Properties Source: https://hlsjs.video-dev.org/api-docs/index Access and modify various playback-related properties of the hls.js instance. ```APIDOC ## Hls.js Properties ### startLevel * **Description**: Return the desired start level for the first fragment that will be loaded. The default value of -1 indicates automatic start level selection. Setting hls.nextAutoLevel without setting a startLevel will result in the nextAutoLevel value being used for one fragment load. * **Type**: `number` * **Access**: Read/Write ### startPosition * **Description**: Get the startPosition set on startLoad(position) or on autostart with config.startPosition * **Type**: `number` * **Access**: Readonly ### subtitleDisplay * **Description**: Whether subtitle display is enabled or not * **Type**: `boolean` * **Access**: Read/Write ### subtitleTrack * **Description**: Index of the selected subtitle track (index in subtitle track lists) * **Type**: `number` * **Access**: Read/Write ### subtitleTracks * **Description**: Get alternate subtitle tracks list from playlist * **Type**: `MediaPlaylist[]` * **Access**: Readonly ### targetLatency * **Description**: Target distance from the edge as calculated by the latency controller * **Type**: `number` * **Access**: Read/Write ### ttfbEstimate * **Description**: Get time to first byte estimate * **Type**: `number` * **Access**: Readonly ### url * **Description**: Gets the currently loaded URL * **Type**: `string` * **Access**: Readonly ### userConfig * **Description**: The configuration object provided on player instantiation. * **Type**: `Partial` * **Access**: Readonly ### version * **Description**: Get the video-dev/hls.js package version. * **Type**: `string` * **Access**: Static Readonly ``` -------------------------------- ### Manage Media Element Attachment Source: https://hlsjs.video-dev.org/api-docs/index Handles the attachment and detachment of Hls.js to HTML media elements. Includes methods for transferring media resources. ```javascript attachMedia(data: HTMLMediaElement): void; detachMedia(): void; transferMedia(): void; recoverMediaError(): void; ``` -------------------------------- ### Event Handling and Emission Source: https://hlsjs.video-dev.org/api-docs/index Allows for registering and removing event listeners, as well as manually triggering events within the Hls.js instance. ```javascript on(event: string, listener: Function, context?: any): void; off(event: string, listener: Function, context?: any, once?: boolean): void; listeners(event: string): Function[]; listenerCount(event: string): number; trigger(event: string, eventObject?: any): void; ``` -------------------------------- ### Hls Class Signature Source: https://hlsjs.video-dev.org/api-docs/index Defines the core Hls class signature, indicating it's the default export and implements the HlsEventEmitter interface. This class is fundamental for HLS playback functionality. ```typescript export default class Hls implements HlsEventEmitter ``` -------------------------------- ### AttrList.parseAttrList() Source: https://hlsjs.video-dev.org/api-docs/hls.js.attrlist Parses an attribute list from a string. It returns a record containing key-value pairs extracted from the input string. ```APIDOC ## AttrList.parseAttrList() ### Description Parses an attribute list from a string and returns a record of key-value pairs. ### Method static ### Signature ``` static parseAttrList(input: string, parsed?: Pick): Record; ``` ### Parameters - **input** (string) - Required - The input string to parse. - **parsed** (Pick) - Optional - An optional object containing variable list, hasVariableRefs, and playlistParsingError properties. ### Returns Record ### Example ```javascript const attributes = AttrList.parseAttrList('key1=value1,key2=value2'); console.log(attributes); // Output: { key1: 'value1', key2: 'value2' } ``` ``` -------------------------------- ### Parse Attribute List String Source: https://hlsjs.video-dev.org/api-docs/hls.js.attrlist Parses a string containing key-value attributes into a JavaScript object. It can optionally utilize existing parsed playlist data. The output is a dictionary of attribute names to their string values. ```typescript static parseAttrList(input: string, parsed?: Pick): Record; ``` -------------------------------- ### FragmentTracker.removeFragmentsInRange() Source: https://hlsjs.video-dev.org/api-docs/hls.js.fragmenttracker Removes fragments from a specified range within the FragmentTracker. This method is useful for managing buffered video segments. ```APIDOC ## FragmentTracker.removeFragmentsInRange() ### Description Removes fragments from a specified time range within the FragmentTracker. This method allows for granular control over which fragments are removed based on playlist type and buffering status. ### Method ``` removeFragmentsInRange(start: number ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.