Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Fix dup maintrack #46

Merged
merged 2 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions hls-video-element.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { CustomVideoElement } from 'custom-media-element';
import Hls from 'hls.js';

declare class HLSVideoElement extends CustomVideoElement {
type HlsVideoElementConstructor<T> = { new(): T };

export function HlsVideoMixin(superclass: any): HlsVideoElementConstructor<HLSVideoElement>;

export class HLSVideoElement extends CustomVideoElement {
/**
* The current instance of the HLS.js library.
*
Expand All @@ -18,11 +22,6 @@ declare class HLSVideoElement extends CustomVideoElement {
*/
attributeChangedCallback(attrName: string, oldValue: any, newValue: any): void;

/**
* Loads the HLS.js instance and attach it to the video element.
*/
load(): Promise<void>;

/**
* Unloads the HLS.js instance and detaches it from the video element.
*/
Expand Down
9 changes: 7 additions & 2 deletions hls-video-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,13 @@ const HlsVideoMixin = (superclass) => {
this.api.on(Hls.Events.MANIFEST_PARSED, (event, data) => {
removeAllMediaTracks();

const videoTrack = this.addVideoTrack('main');
videoTrack.selected = true;
let videoTrack = this.videoTracks.getTrackById('main');

if (!videoTrack) {
videoTrack = this.addVideoTrack('main');
videoTrack.id = 'main';
videoTrack.selected = true;
}

for (const [id, level] of data.levels.entries()) {
const videoRendition = videoTrack.addRendition(
Expand Down