1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update components

This commit is contained in:
Luke Pulverenti 2016-05-09 11:46:47 -04:00
parent da7682e530
commit f2b505a6fb
9 changed files with 106 additions and 67 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "hls.js", "name": "hls.js",
"version": "0.5.29", "version": "0.5.30",
"license": "Apache-2.0", "license": "Apache-2.0",
"description": "Media Source Extension - HLS library, by/for Dailymotion", "description": "Media Source Extension - HLS library, by/for Dailymotion",
"homepage": "https://github.com/dailymotion/hls.js", "homepage": "https://github.com/dailymotion/hls.js",
@ -16,11 +16,11 @@
"test", "test",
"tests" "tests"
], ],
"_release": "0.5.29", "_release": "0.5.30",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v0.5.29", "tag": "v0.5.30",
"commit": "d787e32fed3a72930f4f94f08dce8692dcec0755" "commit": "c8eab206bbd77040cbe9f35f64303775c2065608"
}, },
"_source": "git://github.com/dailymotion/hls.js.git", "_source": "git://github.com/dailymotion/hls.js.git",
"_target": "~0.5.7", "_target": "~0.5.7",

View file

@ -1,6 +1,6 @@
{ {
"name": "hls.js", "name": "hls.js",
"version": "0.5.29", "version": "0.5.30",
"license": "Apache-2.0", "license": "Apache-2.0",
"description": "Media Source Extension - HLS library, by/for Dailymotion", "description": "Media Source Extension - HLS library, by/for Dailymotion",
"homepage": "https://github.com/dailymotion/hls.js", "homepage": "https://github.com/dailymotion/hls.js",

View file

@ -693,9 +693,14 @@ var BufferController = function (_EventHandler) {
ms.removeEventListener('sourceopen', this.onmso); ms.removeEventListener('sourceopen', this.onmso);
ms.removeEventListener('sourceended', this.onmse); ms.removeEventListener('sourceended', this.onmse);
ms.removeEventListener('sourceclose', this.onmsc); ms.removeEventListener('sourceclose', this.onmsc);
try {
// unlink MediaSource from video tag // unlink MediaSource from video tag
this.media.src = ''; this.media.src = '';
this.media.removeAttribute('src'); this.media.removeAttribute('src');
} catch (err) {
_logger.logger.warn('onMediaDetaching:' + err.message + ' while unlinking video.src');
}
this.mediaSource = null; this.mediaSource = null;
this.media = null; this.media = null;
this.pendingTracks = null; this.pendingTracks = null;
@ -1191,7 +1196,7 @@ var LevelController = function (_EventHandler) {
key: 'destroy', key: 'destroy',
value: function destroy() { value: function destroy() {
if (this.timer) { if (this.timer) {
clearInterval(this.timer); clearTimeout(this.timer);
this.timer = null; this.timer = null;
} }
this._manualLevel = -1; this._manualLevel = -1;
@ -1291,17 +1296,18 @@ var LevelController = function (_EventHandler) {
}, { }, {
key: 'setLevelInternal', key: 'setLevelInternal',
value: function setLevelInternal(newLevel) { value: function setLevelInternal(newLevel) {
var levels = this._levels;
// check if level idx is valid // check if level idx is valid
if (newLevel >= 0 && newLevel < this._levels.length) { if (newLevel >= 0 && newLevel < levels.length) {
// stopping live reloading timer if any // stopping live reloading timer if any
if (this.timer) { if (this.timer) {
clearInterval(this.timer); clearTimeout(this.timer);
this.timer = null; this.timer = null;
} }
this._level = newLevel; this._level = newLevel;
_logger.logger.log('switching to level ' + newLevel); _logger.logger.log('switching to level ' + newLevel);
this.hls.trigger(_events2.default.LEVEL_SWITCH, { level: newLevel }); this.hls.trigger(_events2.default.LEVEL_SWITCH, { level: newLevel });
var level = this._levels[newLevel]; var level = levels[newLevel];
// check if we need to load playlist for this level // check if we need to load playlist for this level
if (level.details === undefined || level.details.live === true) { if (level.details === undefined || level.details.live === true) {
// level not retrieved yet, or live playlist we need to (re)load it // level not retrieved yet, or live playlist we need to (re)load it
@ -1366,7 +1372,7 @@ var LevelController = function (_EventHandler) {
this._level = undefined; this._level = undefined;
// stopping live reloading timer if any // stopping live reloading timer if any
if (this.timer) { if (this.timer) {
clearInterval(this.timer); clearTimeout(this.timer);
this.timer = null; this.timer = null;
} }
// redispatch same error but with fatal set to true // redispatch same error but with fatal set to true
@ -1379,18 +1385,32 @@ var LevelController = function (_EventHandler) {
}, { }, {
key: 'onLevelLoaded', key: 'onLevelLoaded',
value: function onLevelLoaded(data) { value: function onLevelLoaded(data) {
// check if current playlist is a live playlist // only process level loaded events matching with expected level
if (data.details.live && !this.timer) { if (data.level === this._level) {
// if live playlist we will have to reload it periodically var newDetails = data.details;
// set reload period to playlist target duration // if current playlist is a live playlist, arm a timer to reload it
this.timer = setInterval(this.ontick, 1000 * data.details.targetduration); if (newDetails.live) {
var reloadInterval = 1000 * newDetails.targetduration,
curLevel = this._levels[data.level],
curDetails = curLevel.details;
if (curDetails && newDetails.endSN === curDetails.endSN) {
// follow HLS Spec, If the client reloads a Playlist file and finds that it has not
// changed then it MUST wait for a period of one-half the target
// duration before retrying.
reloadInterval /= 2;
_logger.logger.log('same live playlist, reload twice faster');
} }
if (!data.details.live && this.timer) { // decrement reloadInterval with level loading delay
// playlist is not live and timer is armed : stopping it reloadInterval -= performance.now() - data.stats.trequest;
clearInterval(this.timer); // in any case, don't reload more than every second
reloadInterval = Math.max(1000, Math.round(reloadInterval));
_logger.logger.log('live playlist, reload in ' + reloadInterval + ' ms');
this.timer = setTimeout(this.ontick, reloadInterval);
} else {
this.timer = null; this.timer = null;
} }
} }
}
}, { }, {
key: 'tick', key: 'tick',
value: function tick() { value: function tick() {
@ -1412,10 +1432,13 @@ var LevelController = function (_EventHandler) {
return this._level; return this._level;
}, },
set: function set(newLevel) { set: function set(newLevel) {
if (this._levels && this._levels.length > newLevel && (this._level !== newLevel || this._levels[newLevel].details === undefined)) { var levels = this._levels;
if (levels && levels.length > newLevel) {
if (this._level !== newLevel || levels[newLevel].details === undefined) {
this.setLevelInternal(newLevel); this.setLevelInternal(newLevel);
} }
} }
}
}, { }, {
key: 'manualLevel', key: 'manualLevel',
get: function get() { get: function get() {
@ -1423,6 +1446,9 @@ var LevelController = function (_EventHandler) {
}, },
set: function set(newLevel) { set: function set(newLevel) {
this._manualLevel = newLevel; this._manualLevel = newLevel;
if (this._startLevel === undefined) {
this._startLevel = newLevel;
}
if (newLevel !== -1) { if (newLevel !== -1) {
this.level = newLevel; this.level = newLevel;
} }
@ -5460,12 +5486,6 @@ var BufferHelper = function () {
buffered2.push(buffered[i]); buffered2.push(buffered[i]);
} }
} }
// in case current position is located before buffered time ranges, report area as not buffered
if (buffered2.length && pos < buffered2[0].start) {
return { len: 0, start: pos, end: pos, nextStart: buffered2[0].start };
}
for (i = 0, bufferLen = 0, bufferStart = bufferEnd = pos; i < buffered2.length; i++) { for (i = 0, bufferLen = 0, bufferStart = bufferEnd = pos; i < buffered2.length; i++) {
var start = buffered2[i].start, var start = buffered2[i].start,
end = buffered2[i].end; end = buffered2[i].end;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{ {
"name": "hls.js", "name": "hls.js",
"version": "0.5.29", "version": "0.5.30",
"license": "Apache-2.0", "license": "Apache-2.0",
"description": "Media Source Extension - HLS library, by/for Dailymotion", "description": "Media Source Extension - HLS library, by/for Dailymotion",
"homepage": "https://github.com/dailymotion/hls.js", "homepage": "https://github.com/dailymotion/hls.js",

View file

@ -63,9 +63,14 @@ class BufferController extends EventHandler {
ms.removeEventListener('sourceopen', this.onmso); ms.removeEventListener('sourceopen', this.onmso);
ms.removeEventListener('sourceended', this.onmse); ms.removeEventListener('sourceended', this.onmse);
ms.removeEventListener('sourceclose', this.onmsc); ms.removeEventListener('sourceclose', this.onmsc);
try {
// unlink MediaSource from video tag // unlink MediaSource from video tag
this.media.src = ''; this.media.src = '';
this.media.removeAttribute('src'); this.media.removeAttribute('src');
} catch(err) {
logger.warn(`onMediaDetaching:${err.message} while unlinking video.src`);
}
this.mediaSource = null; this.mediaSource = null;
this.media = null; this.media = null;
this.pendingTracks = null; this.pendingTracks = null;

View file

@ -20,7 +20,7 @@ class LevelController extends EventHandler {
destroy() { destroy() {
if (this.timer) { if (this.timer) {
clearInterval(this.timer); clearTimeout(this.timer);
this.timer = null; this.timer = null;
} }
this._manualLevel = -1; this._manualLevel = -1;
@ -113,24 +113,27 @@ class LevelController extends EventHandler {
} }
set level(newLevel) { set level(newLevel) {
if (this._levels && this._levels.length > newLevel && let levels = this._levels;
(this._level !== newLevel || this._levels[newLevel].details === undefined)) { if (levels && levels.length > newLevel) {
if (this._level !== newLevel || levels[newLevel].details === undefined) {
this.setLevelInternal(newLevel); this.setLevelInternal(newLevel);
} }
} }
}
setLevelInternal(newLevel) { setLevelInternal(newLevel) {
let levels = this._levels;
// check if level idx is valid // check if level idx is valid
if (newLevel >= 0 && newLevel < this._levels.length) { if (newLevel >= 0 && newLevel < levels.length) {
// stopping live reloading timer if any // stopping live reloading timer if any
if (this.timer) { if (this.timer) {
clearInterval(this.timer); clearTimeout(this.timer);
this.timer = null; this.timer = null;
} }
this._level = newLevel; this._level = newLevel;
logger.log(`switching to level ${newLevel}`); logger.log(`switching to level ${newLevel}`);
this.hls.trigger(Event.LEVEL_SWITCH, {level: newLevel}); this.hls.trigger(Event.LEVEL_SWITCH, {level: newLevel});
var level = this._levels[newLevel]; var level = levels[newLevel];
// check if we need to load playlist for this level // check if we need to load playlist for this level
if (level.details === undefined || level.details.live === true) { if (level.details === undefined || level.details.live === true) {
// level not retrieved yet, or live playlist we need to (re)load it // level not retrieved yet, or live playlist we need to (re)load it
@ -150,6 +153,9 @@ class LevelController extends EventHandler {
set manualLevel(newLevel) { set manualLevel(newLevel) {
this._manualLevel = newLevel; this._manualLevel = newLevel;
if (this._startLevel === undefined) {
this._startLevel = newLevel;
}
if (newLevel !== -1) { if (newLevel !== -1) {
this.level = newLevel; this.level = newLevel;
} }
@ -222,7 +228,7 @@ class LevelController extends EventHandler {
this._level = undefined; this._level = undefined;
// stopping live reloading timer if any // stopping live reloading timer if any
if (this.timer) { if (this.timer) {
clearInterval(this.timer); clearTimeout(this.timer);
this.timer = null; this.timer = null;
} }
// redispatch same error but with fatal set to true // redispatch same error but with fatal set to true
@ -234,18 +240,32 @@ class LevelController extends EventHandler {
} }
onLevelLoaded(data) { onLevelLoaded(data) {
// check if current playlist is a live playlist // only process level loaded events matching with expected level
if (data.details.live && !this.timer) { if (data.level === this._level) {
// if live playlist we will have to reload it periodically let newDetails = data.details;
// set reload period to playlist target duration // if current playlist is a live playlist, arm a timer to reload it
this.timer = setInterval(this.ontick, 1000 * data.details.targetduration); if (newDetails.live) {
let reloadInterval = 1000*newDetails.targetduration,
curLevel = this._levels[data.level],
curDetails = curLevel.details;
if (curDetails && newDetails.endSN === curDetails.endSN) {
// follow HLS Spec, If the client reloads a Playlist file and finds that it has not
// changed then it MUST wait for a period of one-half the target
// duration before retrying.
reloadInterval /=2;
logger.log(`same live playlist, reload twice faster`);
} }
if (!data.details.live && this.timer) { // decrement reloadInterval with level loading delay
// playlist is not live and timer is armed : stopping it reloadInterval -= performance.now() - data.stats.trequest;
clearInterval(this.timer); // in any case, don't reload more than every second
reloadInterval = Math.max(1000,Math.round(reloadInterval));
logger.log(`live playlist, reload in ${reloadInterval} ms`);
this.timer = setTimeout(this.ontick,reloadInterval);
} else {
this.timer = null; this.timer = null;
} }
} }
}
tick() { tick() {
var levelId = this._level; var levelId = this._level;

View file

@ -55,12 +55,6 @@ class BufferHelper {
buffered2.push(buffered[i]); buffered2.push(buffered[i]);
} }
} }
// in case current position is located before buffered time ranges, report area as not buffered
if (buffered2.length && pos < buffered2[0].start) {
return {len: 0, start: pos, end: pos, nextStart : buffered2[0].start};
}
for (i = 0, bufferLen = 0, bufferStart = bufferEnd = pos; i < buffered2.length; i++) { for (i = 0, bufferLen = 0, bufferStart = bufferEnd = pos; i < buffered2.length; i++) {
var start = buffered2[i].start, var start = buffered2[i].start,
end = buffered2[i].end; end = buffered2[i].end;