Skip to content

Commit

Permalink
fix: cache HLS source (vime-js#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
zshall committed Jul 23, 2024
1 parent bfa8dfb commit f40c63e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/core/src/components/providers/hls/hls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,19 @@ export class HLS implements MediaFileProvider {
this.destroyHls();
}

_hlsSrc: string | undefined;
get src(): string | undefined {
if (isNil(this.videoProvider)) return undefined;
const sources = this.videoProvider.querySelectorAll('source');
const currSource = Array.from(sources).find(
source => hlsRegex.test(source.src) || hlsTypeRegex.test(source.type),
source => hlsRegex.test(source.src) || hlsTypeRegex.test(source.type)
);
if (!isNil(currSource) && !currSource?.src?.startsWith('blob:')) {
this._hlsSrc = currSource?.src;
} else if (isNil(currSource)) {
return this._hlsSrc;
}

return currSource?.src;
}

Expand Down

0 comments on commit f40c63e

Please # to comment.