Skip to content

Commit

Permalink
Fix access of mediaSrc value
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonatangcavalcanti committed Aug 4, 2024
1 parent cedf96d commit cd98207
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/controller/buffer-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1026,9 +1026,9 @@ export default class BufferController implements ComponentAPI {
};

private get mediaSrc(): string | undefined {
const media =
(this.media?.firstChild as HTMLSourceElement | null) || this.media;
return media?.src;
if (!this.media) return undefined;
const media = getSourceChild(this.media) || this.media;
return media.src;
}

private _onSBUpdateStart(type: SourceBufferName) {
Expand Down Expand Up @@ -1195,3 +1195,7 @@ function addSource(media: HTMLMediaElement, url: string) {
source.src = url;
media.appendChild(source);
}

function getSourceChild(media: HTMLMediaElement): HTMLSourceElement | null {
return media.querySelector('source');
}

0 comments on commit cd98207

Please sign in to comment.