live stream support
This commit is contained in:
@@ -27,3 +27,23 @@ App.constants = {
|
||||
FAVORITES_VISIBILITY_KEY: 'favoritesVisible',
|
||||
PREFERRED_QUALITY_KEY: 'preferredQuality'
|
||||
};
|
||||
|
||||
// Lazily injects hls.js the first time a stream actually needs it. Sessions
|
||||
// that only browse thumbnails, or that play native/MP4, never download it.
|
||||
// Resolves with window.Hls (or null if loading failed).
|
||||
App.ensureHls = function() {
|
||||
if (window.Hls) return Promise.resolve(window.Hls);
|
||||
if (App._hlsPromise) return App._hlsPromise;
|
||||
App._hlsPromise = new Promise((resolve, reject) => {
|
||||
const script = document.createElement('script');
|
||||
script.src = 'https://cdn.jsdelivr.net/npm/hls.js@1.5';
|
||||
script.async = true;
|
||||
script.onload = () => resolve(window.Hls || null);
|
||||
script.onerror = () => {
|
||||
App._hlsPromise = null;
|
||||
reject(new Error('Failed to load hls.js'));
|
||||
};
|
||||
document.head.appendChild(script);
|
||||
});
|
||||
return App._hlsPromise;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user