mirror of https://bitbucket.org/ausocean/av.git
Merged in m3u-live-minor (pull request #358)
mjpeg-player: added reloading of live playlists Approved-by: Saxon Milton
This commit is contained in:
commit
83ee218be6
|
@ -2,46 +2,40 @@
|
|||
* Level Controller
|
||||
*/
|
||||
|
||||
import Event from '../events';
|
||||
import EventHandler from '../event-handler';
|
||||
import { logger } from '../utils/logger';
|
||||
import { ErrorTypes, ErrorDetails } from '../errors';
|
||||
import { isCodecSupportedInMp4 } from '../utils/codecs';
|
||||
import { addGroupId, computeReloadInterval } from './level-helper';
|
||||
import Event from '../events.js';
|
||||
import EventHandler from '../event-handler.js';
|
||||
import { addGroupId, computeReloadInterval } from './level-helper.js';
|
||||
|
||||
const { performance } = window;
|
||||
let chromeOrFirefox;
|
||||
|
||||
export default class LevelController extends EventHandler {
|
||||
constructor (hls) {
|
||||
constructor(hls) {
|
||||
super(hls,
|
||||
Event.MANIFEST_LOADED,
|
||||
Event.LEVEL_LOADED,
|
||||
Event.AUDIO_TRACK_SWITCHED,
|
||||
Event.FRAG_LOADED,
|
||||
Event.ERROR);
|
||||
Event.LEVEL_LOADED);
|
||||
|
||||
this.canload = false;
|
||||
this.currentLevelIndex = null;
|
||||
this.manualLevelIndex = -1;
|
||||
this.currentLvlIdx = 0;
|
||||
this.manualLvlIdx = -1;
|
||||
this.timer = null;
|
||||
|
||||
chromeOrFirefox = /chrome|firefox/.test(navigator.userAgent.toLowerCase());
|
||||
}
|
||||
|
||||
onHandlerDestroying () {
|
||||
onHandlerDestroying() {
|
||||
this.clearTimer();
|
||||
this.manualLevelIndex = -1;
|
||||
this.manualLvlIdx = -1;
|
||||
}
|
||||
|
||||
clearTimer () {
|
||||
clearTimer() {
|
||||
if (this.timer !== null) {
|
||||
clearTimeout(this.timer);
|
||||
this.timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
startLoad () {
|
||||
startLoad() {
|
||||
let levels = this._levels;
|
||||
|
||||
this.canload = true;
|
||||
|
@ -63,11 +57,11 @@ export default class LevelController extends EventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
stopLoad () {
|
||||
stopLoad() {
|
||||
this.canload = false;
|
||||
}
|
||||
|
||||
onManifestLoaded (data) {
|
||||
onManifestLoaded(data) {
|
||||
let levels = [];
|
||||
let audioTracks = [];
|
||||
let bitrateStart;
|
||||
|
@ -85,12 +79,6 @@ export default class LevelController extends EventHandler {
|
|||
videoCodecFound = videoCodecFound || !!level.videoCodec;
|
||||
audioCodecFound = audioCodecFound || !!level.audioCodec;
|
||||
|
||||
// erase audio codec info if browser does not support mp4a.40.34.
|
||||
// demuxer will autodetect codec and fallback to mpeg/audio
|
||||
if (chromeOrFirefox && level.audioCodec && level.audioCodec.indexOf('mp4a.40.34') !== -1) {
|
||||
level.audioCodec = undefined;
|
||||
}
|
||||
|
||||
levelFromSet = levelSet[level.bitrate]; // FIXME: we would also have to match the resolution here
|
||||
|
||||
if (!levelFromSet) {
|
||||
|
@ -113,24 +101,6 @@ export default class LevelController extends EventHandler {
|
|||
}
|
||||
});
|
||||
|
||||
// remove audio-only level if we also have levels with audio+video codecs signalled
|
||||
if (videoCodecFound && audioCodecFound) {
|
||||
levels = levels.filter(({ videoCodec }) => !!videoCodec);
|
||||
}
|
||||
|
||||
// only keep levels with supported audio/video codecs
|
||||
levels = levels.filter(({ audioCodec, videoCodec }) => {
|
||||
return (!audioCodec || isCodecSupportedInMp4(audioCodec, 'audio')) && (!videoCodec || isCodecSupportedInMp4(videoCodec, 'video'));
|
||||
});
|
||||
|
||||
if (data.audioTracks) {
|
||||
audioTracks = data.audioTracks.filter(track => !track.audioCodec || isCodecSupportedInMp4(track.audioCodec, 'audio'));
|
||||
// Reassign id's after filtering since they're used as array indices
|
||||
audioTracks.forEach((track, index) => {
|
||||
track.id = index;
|
||||
});
|
||||
}
|
||||
|
||||
if (levels.length > 0) {
|
||||
// start bitrate is the first bitrate of the manifest
|
||||
bitrateStart = levels[0].bitrate;
|
||||
|
@ -141,7 +111,6 @@ export default class LevelController extends EventHandler {
|
|||
for (let i = 0; i < levels.length; i++) {
|
||||
if (levels[i].bitrate === bitrateStart) {
|
||||
this._firstLevel = i;
|
||||
logger.log(`manifest loaded,${levels.length} level(s) found, first bitrate:${bitrateStart}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -167,34 +136,34 @@ export default class LevelController extends EventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
get levels () {
|
||||
get levels() {
|
||||
return this._levels;
|
||||
}
|
||||
|
||||
get level () {
|
||||
return this.currentLevelIndex;
|
||||
get level() {
|
||||
return this.curLvlIdx;
|
||||
}
|
||||
|
||||
set level (newLevel) {
|
||||
set level(newLevel) {
|
||||
let levels = this._levels;
|
||||
if (levels) {
|
||||
newLevel = Math.min(newLevel, levels.length - 1);
|
||||
if (this.currentLevelIndex !== newLevel || !levels[newLevel].details) {
|
||||
if (this.curLvlIdx !== newLevel || !levels[newLevel].details) {
|
||||
this.setLevelInternal(newLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setLevelInternal (newLevel) {
|
||||
setLevelInternal(newLevel) {
|
||||
const levels = this._levels;
|
||||
const hls = this.hls;
|
||||
// check if level idx is valid
|
||||
if (newLevel >= 0 && newLevel < levels.length) {
|
||||
// stopping live reloading timer if any
|
||||
this.clearTimer();
|
||||
if (this.currentLevelIndex !== newLevel) {
|
||||
logger.log(`switching to level ${newLevel}`);
|
||||
this.currentLevelIndex = newLevel;
|
||||
if (this.curLvlIdx !== newLevel) {
|
||||
console.log(`switching to level ${newLevel}`);
|
||||
this.curLvlIdx = newLevel;
|
||||
const levelProperties = levels[newLevel];
|
||||
levelProperties.level = newLevel;
|
||||
hls.trigger(Event.LEVEL_SWITCHING, levelProperties);
|
||||
|
@ -220,12 +189,12 @@ export default class LevelController extends EventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
get manualLevel () {
|
||||
return this.manualLevelIndex;
|
||||
get manualLevel() {
|
||||
return this.manualLvlIdx;
|
||||
}
|
||||
|
||||
set manualLevel (newLevel) {
|
||||
this.manualLevelIndex = newLevel;
|
||||
set manualLevel(newLevel) {
|
||||
this.manualLvlIdx = newLevel;
|
||||
if (this._startLevel === undefined) {
|
||||
this._startLevel = newLevel;
|
||||
}
|
||||
|
@ -235,15 +204,15 @@ export default class LevelController extends EventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
get firstLevel () {
|
||||
get firstLevel() {
|
||||
return this._firstLevel;
|
||||
}
|
||||
|
||||
set firstLevel (newLevel) {
|
||||
set firstLevel(newLevel) {
|
||||
this._firstLevel = newLevel;
|
||||
}
|
||||
|
||||
get startLevel () {
|
||||
get startLevel() {
|
||||
// hls.startLevel takes precedence over config.startLevel
|
||||
// if none of these values are defined, fallback on this._firstLevel (first quality level appearing in variant manifest)
|
||||
if (this._startLevel === undefined) {
|
||||
|
@ -258,210 +227,53 @@ export default class LevelController extends EventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
set startLevel (newLevel) {
|
||||
set startLevel(newLevel) {
|
||||
this._startLevel = newLevel;
|
||||
}
|
||||
|
||||
onError (data) {
|
||||
if (data.fatal) {
|
||||
if (data.type === ErrorTypes.NETWORK_ERROR) {
|
||||
this.clearTimer();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let levelError = false, fragmentError = false;
|
||||
let levelIndex;
|
||||
|
||||
// try to recover not fatal errors
|
||||
switch (data.details) {
|
||||
case ErrorDetails.FRAG_LOAD_ERROR:
|
||||
case ErrorDetails.FRAG_LOAD_TIMEOUT:
|
||||
case ErrorDetails.KEY_LOAD_ERROR:
|
||||
case ErrorDetails.KEY_LOAD_TIMEOUT:
|
||||
levelIndex = data.frag.level;
|
||||
fragmentError = true;
|
||||
break;
|
||||
case ErrorDetails.LEVEL_LOAD_ERROR:
|
||||
case ErrorDetails.LEVEL_LOAD_TIMEOUT:
|
||||
levelIndex = data.context.level;
|
||||
levelError = true;
|
||||
break;
|
||||
case ErrorDetails.REMUX_ALLOC_ERROR:
|
||||
levelIndex = data.level;
|
||||
levelError = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (levelIndex !== undefined) {
|
||||
this.recoverLevel(data, levelIndex, levelError, fragmentError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch to a redundant stream if any available.
|
||||
* If redundant stream is not available, emergency switch down if ABR mode is enabled.
|
||||
*
|
||||
* @param {Object} errorEvent
|
||||
* @param {Number} levelIndex current level index
|
||||
* @param {Boolean} levelError
|
||||
* @param {Boolean} fragmentError
|
||||
*/
|
||||
// FIXME Find a better abstraction where fragment/level retry management is well decoupled
|
||||
recoverLevel (errorEvent, levelIndex, levelError, fragmentError) {
|
||||
let { config } = this.hls;
|
||||
let { details: errorDetails } = errorEvent;
|
||||
let level = this._levels[levelIndex];
|
||||
let redundantLevels, delay, nextLevel;
|
||||
|
||||
level.loadError++;
|
||||
level.fragmentError = fragmentError;
|
||||
|
||||
if (levelError) {
|
||||
if ((this.levelRetryCount + 1) <= config.levelLoadingMaxRetry) {
|
||||
// exponential backoff capped to max retry timeout
|
||||
delay = Math.min(Math.pow(2, this.levelRetryCount) * config.levelLoadingRetryDelay, config.levelLoadingMaxRetryTimeout);
|
||||
// Schedule level reload
|
||||
this.timer = setTimeout(() => this.loadLevel(), delay);
|
||||
// boolean used to inform stream controller not to switch back to IDLE on non fatal error
|
||||
errorEvent.levelRetry = true;
|
||||
this.levelRetryCount++;
|
||||
logger.warn(`level controller, ${errorDetails}, retry in ${delay} ms, current retry count is ${this.levelRetryCount}`);
|
||||
} else {
|
||||
logger.error(`level controller, cannot recover from ${errorDetails} error`);
|
||||
this.currentLevelIndex = null;
|
||||
// stopping live reloading timer if any
|
||||
this.clearTimer();
|
||||
// switch error to fatal
|
||||
errorEvent.fatal = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Try any redundant streams if available for both errors: level and fragment
|
||||
// If level.loadError reaches redundantLevels it means that we tried them all, no hope => let's switch down
|
||||
if (levelError || fragmentError) {
|
||||
redundantLevels = level.url.length;
|
||||
|
||||
if (redundantLevels > 1 && level.loadError < redundantLevels) {
|
||||
level.urlId = (level.urlId + 1) % redundantLevels;
|
||||
level.details = undefined;
|
||||
|
||||
logger.warn(`level controller, ${errorDetails} for level ${levelIndex}: switching to redundant URL-id ${level.urlId}`);
|
||||
|
||||
// console.log('Current audio track group ID:', this.hls.audioTracks[this.hls.audioTrack].groupId);
|
||||
// console.log('New video quality level audio group id:', level.attrs.AUDIO);
|
||||
} else {
|
||||
// Search for available level
|
||||
if (this.manualLevelIndex === -1) {
|
||||
// When lowest level has been reached, let's start hunt from the top
|
||||
nextLevel = (levelIndex === 0) ? this._levels.length - 1 : levelIndex - 1;
|
||||
logger.warn(`level controller, ${errorDetails}: switch to ${nextLevel}`);
|
||||
this.hls.nextAutoLevel = this.currentLevelIndex = nextLevel;
|
||||
} else if (fragmentError) {
|
||||
// Allow fragment retry as long as configuration allows.
|
||||
// reset this._level so that another call to set level() will trigger again a frag load
|
||||
logger.warn(`level controller, ${errorDetails}: reload a fragment`);
|
||||
this.currentLevelIndex = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// reset errors on the successful load of a fragment
|
||||
onFragLoaded ({ frag }) {
|
||||
if (frag !== undefined && frag.type === 'main') {
|
||||
const level = this._levels[frag.level];
|
||||
if (level !== undefined) {
|
||||
level.fragmentError = false;
|
||||
level.loadError = 0;
|
||||
this.levelRetryCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onLevelLoaded (data) {
|
||||
onLevelLoaded(data) {
|
||||
const { level, details } = data;
|
||||
// only process level loaded events matching with expected level
|
||||
if (level !== this.currentLevelIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
const curLevel = this._levels[level];
|
||||
// reset level load error counter on successful level loaded only if there is no issues with fragments
|
||||
if (!curLevel.fragmentError) {
|
||||
curLevel.loadError = 0;
|
||||
this.levelRetryCount = 0;
|
||||
}
|
||||
// if current playlist is a live playlist, arm a timer to reload it
|
||||
if (details.live) {
|
||||
const reloadInterval = computeReloadInterval(curLevel.details, details, data.stats.trequest);
|
||||
logger.log(`live playlist, reload in ${Math.round(reloadInterval)} ms`);
|
||||
console.log(`live playlist, reload in ${Math.round(reloadInterval)} ms`);
|
||||
this.timer = setTimeout(() => this.loadLevel(), reloadInterval);
|
||||
} else {
|
||||
this.clearTimer();
|
||||
}
|
||||
}
|
||||
|
||||
onAudioTrackSwitched (data) {
|
||||
const audioGroupId = this.hls.audioTracks[data.id].groupId;
|
||||
loadLevel() {
|
||||
console.log('call to loadLevel, index: ' + this.curLvlIdx + "canload: " + this.canload);
|
||||
|
||||
const currentLevel = this.hls.levels[this.currentLevelIndex];
|
||||
if (!currentLevel) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentLevel.audioGroupIds) {
|
||||
let urlId = -1;
|
||||
|
||||
for (let i = 0; i < currentLevel.audioGroupIds.length; i++) {
|
||||
if (currentLevel.audioGroupIds[i] === audioGroupId) {
|
||||
urlId = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (urlId !== currentLevel.urlId) {
|
||||
currentLevel.urlId = urlId;
|
||||
this.startLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadLevel () {
|
||||
logger.debug('call to loadLevel');
|
||||
|
||||
if (this.currentLevelIndex !== null && this.canload) {
|
||||
const levelObject = this._levels[this.currentLevelIndex];
|
||||
if (this.curLvlIdx !== null && this.canload) {
|
||||
const levelObject = this._levels[this.curLvlIdx];
|
||||
|
||||
if (typeof levelObject === 'object' &&
|
||||
levelObject.url.length > 0) {
|
||||
const level = this.currentLevelIndex;
|
||||
const level = this.curLvlIdx;
|
||||
const id = levelObject.urlId;
|
||||
const url = levelObject.url[id];
|
||||
|
||||
logger.log(`Attempt loading level index ${level} with URL-id ${id}`);
|
||||
|
||||
// console.log('Current audio track group ID:', this.hls.audioTracks[this.hls.audioTrack].groupId);
|
||||
// console.log('New video quality level audio group id:', levelObject.attrs.AUDIO, level);
|
||||
console.log(`Attempt loading level index ${level} with URL-id ${id}`);
|
||||
|
||||
this.hls.trigger(Event.LEVEL_LOADING, { url, level, id });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get nextLoadLevel () {
|
||||
if (this.manualLevelIndex !== -1) {
|
||||
return this.manualLevelIndex;
|
||||
get nextLoadLevel() {
|
||||
if (this.manualLvlIdx !== -1) {
|
||||
return this.manualLvlIdx;
|
||||
} else {
|
||||
return this.hls.nextAutoLevel;
|
||||
}
|
||||
}
|
||||
|
||||
set nextLoadLevel (nextLevel) {
|
||||
set nextLoadLevel(nextLevel) {
|
||||
this.level = nextLevel;
|
||||
if (this.manualLevelIndex === -1) {
|
||||
if (this.manualLvlIdx === -1) {
|
||||
this.hls.nextAutoLevel = nextLevel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,26 +7,24 @@
|
|||
*
|
||||
* */
|
||||
|
||||
import { logger } from '../utils/logger';
|
||||
|
||||
export function addGroupId (level, type, id) {
|
||||
export function addGroupId(level, type, id) {
|
||||
switch (type) {
|
||||
case 'audio':
|
||||
if (!level.audioGroupIds) {
|
||||
level.audioGroupIds = [];
|
||||
}
|
||||
level.audioGroupIds.push(id);
|
||||
break;
|
||||
case 'text':
|
||||
if (!level.textGroupIds) {
|
||||
level.textGroupIds = [];
|
||||
}
|
||||
level.textGroupIds.push(id);
|
||||
break;
|
||||
case 'audio':
|
||||
if (!level.audioGroupIds) {
|
||||
level.audioGroupIds = [];
|
||||
}
|
||||
level.audioGroupIds.push(id);
|
||||
break;
|
||||
case 'text':
|
||||
if (!level.textGroupIds) {
|
||||
level.textGroupIds = [];
|
||||
}
|
||||
level.textGroupIds.push(id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
export function updatePTS (fragments, fromIdx, toIdx) {
|
||||
export function updatePTS(fragments, fromIdx, toIdx) {
|
||||
let fragFrom = fragments[fromIdx], fragTo = fragments[toIdx], fragToPTS = fragTo.startPTS;
|
||||
// if we know startPTS[toIdx]
|
||||
if (Number.isFinite(fragToPTS)) {
|
||||
|
@ -35,12 +33,12 @@ export function updatePTS (fragments, fromIdx, toIdx) {
|
|||
if (toIdx > fromIdx) {
|
||||
fragFrom.duration = fragToPTS - fragFrom.start;
|
||||
if (fragFrom.duration < 0) {
|
||||
logger.warn(`negative duration computed for frag ${fragFrom.sn},level ${fragFrom.level}, there should be some duration drift between playlist and fragment!`);
|
||||
console.warn(`negative duration computed for frag ${fragFrom.sn},level ${fragFrom.level}, there should be some duration drift between playlist and fragment!`);
|
||||
}
|
||||
} else {
|
||||
fragTo.duration = fragFrom.start - fragToPTS;
|
||||
if (fragTo.duration < 0) {
|
||||
logger.warn(`negative duration computed for frag ${fragTo.sn},level ${fragTo.level}, there should be some duration drift between playlist and fragment!`);
|
||||
console.warn(`negative duration computed for frag ${fragTo.sn},level ${fragTo.level}, there should be some duration drift between playlist and fragment!`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -53,7 +51,7 @@ export function updatePTS (fragments, fromIdx, toIdx) {
|
|||
}
|
||||
}
|
||||
|
||||
export function updateFragPTSDTS (details, frag, startPTS, endPTS, startDTS, endDTS) {
|
||||
export function updateFragPTSDTS(details, frag, startPTS, endPTS, startDTS, endDTS) {
|
||||
// update frag PTS/DTS
|
||||
let maxStartPTS = startPTS;
|
||||
if (Number.isFinite(frag.startPTS)) {
|
||||
|
@ -109,7 +107,7 @@ export function updateFragPTSDTS (details, frag, startPTS, endPTS, startDTS, end
|
|||
return drift;
|
||||
}
|
||||
|
||||
export function mergeDetails (oldDetails, newDetails) {
|
||||
export function mergeDetails(oldDetails, newDetails) {
|
||||
// potentially retrieve cached initsegment
|
||||
if (newDetails.initSegment && oldDetails.initSegment) {
|
||||
newDetails.initSegment = oldDetails.initSegment;
|
||||
|
@ -138,7 +136,7 @@ export function mergeDetails (oldDetails, newDetails) {
|
|||
}
|
||||
|
||||
if (ccOffset) {
|
||||
logger.log('discontinuity sliding from playlist, take drift into account');
|
||||
console.log('discontinuity sliding from playlist, take drift into account');
|
||||
const newFragments = newDetails.fragments;
|
||||
for (let i = 0; i < newFragments.length; i++) {
|
||||
newFragments[i].cc += ccOffset;
|
||||
|
@ -159,7 +157,7 @@ export function mergeDetails (oldDetails, newDetails) {
|
|||
newDetails.PTSKnown = oldDetails.PTSKnown;
|
||||
}
|
||||
|
||||
export function mergeSubtitlePlaylists (oldPlaylist, newPlaylist, referenceStart = 0) {
|
||||
export function mergeSubtitlePlaylists(oldPlaylist, newPlaylist, referenceStart = 0) {
|
||||
let lastIndex = -1;
|
||||
mapFragmentIntersection(oldPlaylist, newPlaylist, (oldFrag, newFrag, index) => {
|
||||
newFrag.start = oldFrag.start;
|
||||
|
@ -179,7 +177,7 @@ export function mergeSubtitlePlaylists (oldPlaylist, newPlaylist, referenceStart
|
|||
}
|
||||
}
|
||||
|
||||
export function mapFragmentIntersection (oldPlaylist, newPlaylist, intersectionFn) {
|
||||
export function mapFragmentIntersection(oldPlaylist, newPlaylist, intersectionFn) {
|
||||
if (!oldPlaylist || !newPlaylist) {
|
||||
return;
|
||||
}
|
||||
|
@ -198,7 +196,7 @@ export function mapFragmentIntersection (oldPlaylist, newPlaylist, intersectionF
|
|||
}
|
||||
}
|
||||
|
||||
export function adjustSliding (oldPlaylist, newPlaylist) {
|
||||
export function adjustSliding(oldPlaylist, newPlaylist) {
|
||||
const delta = newPlaylist.startSN - oldPlaylist.startSN;
|
||||
const oldFragments = oldPlaylist.fragments;
|
||||
const newFragments = newPlaylist.fragments;
|
||||
|
@ -211,7 +209,7 @@ export function adjustSliding (oldPlaylist, newPlaylist) {
|
|||
}
|
||||
}
|
||||
|
||||
export function computeReloadInterval (currentPlaylist, newPlaylist, lastRequestTime) {
|
||||
export function computeReloadInterval(currentPlaylist, newPlaylist, lastRequestTime) {
|
||||
let reloadInterval = 1000 * (newPlaylist.averagetargetduration ? newPlaylist.averagetargetduration : newPlaylist.targetduration);
|
||||
const minReloadInterval = reloadInterval / 2;
|
||||
if (currentPlaylist && newPlaylist.endSN === currentPlaylist.endSN) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import HlsEvents from './events.js';
|
|||
import PlaylistLoader from './loader/playlist-loader.js';
|
||||
import FragmentLoader from './loader/fragment-loader.js';
|
||||
import StreamController from './controller/stream-controller.js';
|
||||
import LevelController from './controller/level-controller.js';
|
||||
import { hlsDefaultConfig } from './config.js';
|
||||
import { Observer } from './observer.js';
|
||||
|
||||
|
@ -34,6 +35,7 @@ class Hls extends Observer {
|
|||
super();
|
||||
this.pLoader = new PlaylistLoader(this);
|
||||
this.streamController = new StreamController(this);
|
||||
this.levelController = new LevelController(this);
|
||||
this.fragmentLoader = new FragmentLoader(this);
|
||||
|
||||
this.config = hlsDefaultConfig;
|
||||
|
@ -41,6 +43,7 @@ class Hls extends Observer {
|
|||
|
||||
// url is the source URL. Can be relative or absolute.
|
||||
loadSource(url, callback) {
|
||||
this.levelController.startLoad();
|
||||
this.loadSuccess = callback;
|
||||
url = URLToolkit.buildAbsoluteURL(window.location.href, url, { alwaysNormalize: true });
|
||||
this.trigger(HlsEvents.MANIFEST_LOADING, { url: url });
|
||||
|
|
|
@ -80,8 +80,6 @@ class PlayerWorker {
|
|||
if (frame != null) {
|
||||
postMessage({ msg: "frame", data: frame.buffer }, [frame.buffer]);
|
||||
setTimeout(() => { this.start(); }, 1000 / this.frameRate);
|
||||
} else {
|
||||
postMessage({ msg: "stop" });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue