1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00
Daniel Neto 2023-07-03 08:43:01 -03:00
parent cb46edfe52
commit 1aae4c9c1b
35 changed files with 725 additions and 181 deletions

17
node_modules/.package-lock.json generated vendored
View file

@ -721,6 +721,17 @@
"unidragger": "^3.0.0"
}
},
"node_modules/flickity-bg-lazyload": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/flickity-bg-lazyload/-/flickity-bg-lazyload-2.0.0.tgz",
"integrity": "sha512-il5f8gi0GHNGv0mU+rpEfEAnv1VBpYYRKMVsgmFR5hblBlhT6VaQltKTjc8irTgU8lNOdEuaGavW/AE0QzjSMg==",
"dependencies": {
"fizzy-ui-utils": "^3.0.0"
},
"peerDependencies": {
"flickity": "^3.0.0"
}
},
"node_modules/fontawesome-free": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/fontawesome-free/-/fontawesome-free-1.0.4.tgz",
@ -746,9 +757,9 @@
}
},
"node_modules/hls.js": {
"version": "1.4.5",
"resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.4.5.tgz",
"integrity": "sha512-xb7IiSM9apU3tJWb5rdSStobXPNJJykHTwSy7JnLF5y/kLJXWjoR/fEpNBlwYxkKcDiiSfO9SQI8yFravZJxIg=="
"version": "1.4.7",
"resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.4.7.tgz",
"integrity": "sha512-dvwJXLlYES6wb7DR42uuTrio5sUTsIoWbuNeQS4xHMqfVBZ0KAlJlBmjFAo4s20/0XRhsMjWf5bx0kq5Lgvv1w=="
},
"node_modules/ieee754": {
"version": "1.2.1",

19
node_modules/flickity-bg-lazyload/.eslintrc.js generated vendored Normal file
View file

@ -0,0 +1,19 @@
module.exports = {
plugins: [ 'metafizzy' ],
extends: 'plugin:metafizzy/browser',
env: {
browser: true,
commonjs: true,
},
parserOptions: {
ecmaVersion: 2018,
},
globals: {
Flickity: 'readonly',
QUnit: 'readonly',
},
rules: {
'prefer-object-spread': 'error',
},
ignorePatterns: [ 'bower_components' ],
};

1
node_modules/flickity-bg-lazyload/.nvmrc generated vendored Normal file
View file

@ -0,0 +1 @@
16

86
node_modules/flickity-bg-lazyload/README.md generated vendored Normal file
View file

@ -0,0 +1,86 @@
# Flickity background lazyload
Lazyload background images of selected cells.
## Install
Add `bg-lazyload.js` to your scripts.
### Download
[bg-lazyload.js](https://unpkg.com/flickity-bg-lazyload@1/bg-lazyload.js)
### CDN
``` html
<script src="https://unpkg.com/flickity-bg-lazyload@1/bg-lazyload.js"></script>
```
### Package managers
npm: `npm install flickity-bg-lazyload`
Bower: `bower install flickity-bg-lazyload`
## Usage
Set `data-flickity-bg-lazyload` attribute of the cell to the background image's url.
``` html
<div class="carousel">
<div class="carousel-cell" data-flickity-bg-lazyload="oranges.jpg"></div>
<div class="carousel-cell" data-flickity-bg-lazyload="submerge.jpg"></div>
<div class="carousel-cell" data-flickity-bg-lazyload="cat-nose.jpg"></div>
</div>
```
Set `bgLazyLoad` option.
``` js
// lazyloads background image of selected cell
// jQuery
var $carousel = $('.carousel').flickity({
bgLazyLoad: true
});
```
``` js
// vanilla JS
var flkty = new Flickity( '.carousel', {
bgLazyLoad: true
});
```
Set `bgLazyLoad` to a number to load images in adjacent cells.
``` js
bgLazyLoad: 2
// load background images in selected cell
// and next 2 cells
// and previous 2 cells
```
### Webpack & Browserify
``` js
var Flickity = require('flickity-bg-lazyload');
var flkty = new Flickity( '.carousel', {
bgLazyLoad: true
});
```
### RequireJS
``` js
requirejs( [ 'path/to/flickity-bg-lazyload' ], function( Flickity ) {
var flkty = new Flickity( '.carousel', {
bgLazyLoad: true
});
});
```
---
By [Metafizzy 🌈🐻](https://metafizzy.co)

106
node_modules/flickity-bg-lazyload/bg-lazyload.js generated vendored Normal file
View file

@ -0,0 +1,106 @@
/**
* Flickity background lazyload v2.0.0
* lazyload background cell images
*/
( function( window, factory ) {
// universal module definition
if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
require('flickity'),
require('fizzy-ui-utils'),
);
} else {
// browser global
factory(
window.Flickity,
window.fizzyUIUtils,
);
}
}( window, function factory( Flickity, utils ) {
Flickity.create.bgLazyLoad = function() {
this.on( 'select', this.bgLazyLoad );
};
let proto = Flickity.prototype;
const bgLazyloadAttr = 'data-flickity-bg-lazyload';
proto.bgLazyLoad = function() {
let lazyLoad = this.options.bgLazyLoad;
if ( !lazyLoad ) return;
// get adjacent cells, use lazyLoad option for adjacent count
let adjCount = typeof lazyLoad == 'number' ? lazyLoad : 0;
let cellElems = this.getAdjacentCellElements( adjCount );
cellElems.forEach( ( cellElem ) => {
this.bgLazyLoadElem( cellElem );
// select lazy elems in cell
let children = cellElem.querySelectorAll(`[${bgLazyloadAttr}]`);
for ( let child of children ) {
this.bgLazyLoadElem( child );
}
} );
};
proto.bgLazyLoadElem = function( elem ) {
let attr = elem.getAttribute( bgLazyloadAttr );
if ( !attr ) return;
let onComplete = ( event ) => {
this.dispatchEvent( 'bgLazyLoad', event, elem );
};
new BgLazyLoader( elem, attr, onComplete );
};
// -------------------------- LazyBGLoader -------------------------- //
// class to handle loading images
function BgLazyLoader( elem, url, onComplete ) {
this.element = elem;
this.url = url;
this.img = new Image();
this.onComplete = onComplete;
this.load();
}
BgLazyLoader.prototype.handleEvent = utils.handleEvent;
BgLazyLoader.prototype.load = function() {
this.img.addEventListener( 'load', this );
this.img.addEventListener( 'error', this );
// load image
this.img.src = this.url;
// remove attr
this.element.removeAttribute( bgLazyloadAttr );
};
BgLazyLoader.prototype.onload = function( event ) {
this.element.style.backgroundImage = `url("${this.url}")`;
this.complete( event, 'flickity-bg-lazyloaded' );
};
BgLazyLoader.prototype.onerror = function( event ) {
this.complete( event, 'flickity-bg-lazyerror' );
};
BgLazyLoader.prototype.complete = function( event, className ) {
// unbind events
this.img.removeEventListener( 'load', this );
this.img.removeEventListener( 'error', this );
this.element.classList.add( className );
this.onComplete( event );
};
// ----- ----- //
Flickity.BgLazyLoader = BgLazyLoader;
return Flickity;
} ) );

31
node_modules/flickity-bg-lazyload/bower.json generated vendored Normal file
View file

@ -0,0 +1,31 @@
{
"name": "flickity-bg-lazyload",
"description": "Flickity lazyload background images",
"main": "bg-lazyload.js",
"dependencies": {
"flickity": "^3.0.0",
"fizzy-ui-utils": "^3.0.0"
},
"devDependencies": {
},
"keywords": [
"flickity",
"background",
"lazyload",
"image"
],
"license": "MIT",
"homepage": "https://github.com/metafizzy/flickity-bg-lazyload",
"authors": [
"David DeSandro"
],
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"sandbox",
"package.json"
]
}

40
node_modules/flickity-bg-lazyload/package.json generated vendored Normal file
View file

@ -0,0 +1,40 @@
{
"name": "flickity-bg-lazyload",
"version": "2.0.0",
"description": "Flickity lazyload background images",
"main": "bg-lazyload.js",
"peerDependencies": {
"flickity": "^3.0.0"
},
"dependencies": {
"fizzy-ui-utils": "^3.0.0"
},
"devDependencies": {
"eslint": "^8.10.0",
"eslint-plugin-metafizzy": "^2.0.1",
"qunit": "^2.18.0"
},
"scripts": {
"test": "npm run lint",
"lint": "npx eslint ."
},
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/metafizzy/flickity-bg-lazyload.git"
},
"keywords": [
"flickity",
"lazyload",
"background",
"image"
],
"author": "David DeSandro",
"license": "MIT",
"bugs": {
"url": "https://github.com/metafizzy/flickity-bg-lazyload/issues"
},
"homepage": "https://github.com/metafizzy/flickity-bg-lazyload#readme"
}

73
node_modules/flickity-bg-lazyload/sandbox/single.html generated vendored Normal file
View file

@ -0,0 +1,73 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Flickity bgLazyLoad</title>
<link rel="stylesheet" href="../node_modules/flickity/css/flickity.css" media="screen" />
<style>
.carousel {
border: 1px solid;
}
.cell {
width: 80%;
max-width: 500px;
margin-right: 10px;
height: 400px;
background-color: #DDD;
background-size: cover;
}
</style>
</head>
<body>
<h1>Flickity bgLazyLoad</h1>
<div class="carousel">
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/r8p3Xgq.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/q9zO6tw.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/bwy74ok.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/hODreXI.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/UORFJ3w.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/bAZWoqx.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/PgmEBSB.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/aboaFoB.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/LkmcILl.jpg"></div>
</div>
<!-- dependencies -->
<script src="../node_modules/get-size/get-size.js"></script>
<script src="../node_modules/ev-emitter/ev-emitter.js"></script>
<script src="../node_modules/fizzy-ui-utils/utils.js"></script>
<script src="../node_modules/unidragger/unidragger.js"></script>
<!-- Flickity source -->
<script src="../node_modules/flickity/js/cell.js"></script>
<script src="../node_modules/flickity/js/slide.js"></script>
<script src="../node_modules/flickity/js/animate.js"></script>
<script src="../node_modules/flickity/js/core.js"></script>
<script src="../node_modules/flickity/js/drag.js"></script>
<script src="../node_modules/flickity/js/prev-next-button.js"></script>
<script src="../node_modules/flickity/js/page-dots.js"></script>
<script src="../node_modules/flickity/js/player.js"></script>
<script src="../node_modules/flickity/js/add-remove-cell.js"></script>
<script src="../node_modules/flickity/js/lazyload.js"></script>
<script src="../bg-lazyload.js"></script>
<script>
let flkty = new Flickity( '.carousel', {
bgLazyLoad: true
});
flkty.on( 'bgLazyLoad', function( event, elem ) {
console.log( event.type, elem );
});
</script>
</body>
</html>

80
node_modules/flickity-bg-lazyload/test/index.html generated vendored Normal file
View file

@ -0,0 +1,80 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Flickity bg lazyLoad</title>
<link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css" media="screen" />
<link rel="stylesheet" href="../node_modules/flickity/css/flickity.css" media="screen" />
<style>
body {
font-family: sans-serif;
color: #333;
}
.carousel {
border: 1px solid;
width: 400px;
margin-bottom: 40px;
}
.carousel .cell {
width: 100%;
height: 100px;
background: #F09;
font-size: 40px;
color: white;
}
</style>
<!-- dependencies -->
<script src="../node_modules/get-size/get-size.js"></script>
<script src="../node_modules/ev-emitter/ev-emitter.js"></script>
<script src="../node_modules/fizzy-ui-utils/utils.js"></script>
<script src="../node_modules/unidragger/unidragger.js"></script>
<!-- Flickity source -->
<script src="../node_modules/flickity/js/cell.js"></script>
<script src="../node_modules/flickity/js/slide.js"></script>
<script src="../node_modules/flickity/js/animate.js"></script>
<script src="../node_modules/flickity/js/core.js"></script>
<script src="../node_modules/flickity/js/drag.js"></script>
<script src="../node_modules/flickity/js/prev-next-button.js"></script>
<script src="../node_modules/flickity/js/page-dots.js"></script>
<script src="../node_modules/flickity/js/player.js"></script>
<script src="../node_modules/flickity/js/add-remove-cell.js"></script>
<script src="../node_modules/flickity/js/lazyload.js"></script>
<script src="../node_modules/qunit/qunit/qunit.js"></script>
<script src="../bg-lazyload.js"></script>
<!-- turn off accessibility for these tests, causing bugs with dragging tests -->
<script>
Flickity.defaults.accessibility = false;
</script>
<!-- unit tests -->
<script src="test-bg-lazyload.js"></script>
</head>
<body>
<div id="qunit"></div>
<h2>bgLazyLoad</h2>
<div class="carousel carousel--bg-lazyload">
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/r8p3Xgq.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/q9zO6tw.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/bwy74ok.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/hODreXI.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/UORFJ3w.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/bAZWoqx.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/PgmEBSB.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/aboaFoB.jpg"></div>
<div class="cell" data-flickity-bg-lazyload="https://i.imgur.com/LkmcILl.jpg"></div>
</div>
</body>
</html>

View file

@ -0,0 +1,28 @@
QUnit.test( 'bgLazyLoad', function( assert ) {
let done = assert.async();
let carousel = document.querySelector('.carousel--bg-lazyload');
let flkty = new Flickity( carousel, {
bgLazyLoad: 1,
} );
let loadCount = 0;
flkty.on( 'bgLazyLoad', function( event, elem ) {
loadCount++;
assert.equal( event.type, 'load', 'event.type == load' );
assert.ok( elem, 'elem argument there' );
// after first 2 have loaded, select 7th cell
if ( loadCount === 2 ) {
flkty.select( 6 );
}
if ( loadCount === 5 ) {
let loadedImgs = carousel.querySelectorAll('.flickity-bg-lazyloaded');
assert.equal( loadedImgs.length, '5', 'only 5 images loaded' );
done();
}
} );
} );

100
node_modules/hls.js/dist/hls.js generated vendored
View file

@ -539,7 +539,7 @@
// Some browsers don't allow to use bind on console object anyway
// fallback to default if needed
try {
exportedLogger.log("Debug logs enabled for \"" + id + "\" in hls.js version " + "1.4.5");
exportedLogger.log("Debug logs enabled for \"" + id + "\" in hls.js version " + "1.4.7");
} catch (e) {
exportedLogger = fakeLogger;
}
@ -5773,14 +5773,17 @@
var _data$frag, _data$context2;
// Search for next level to retry
var nextLevel = -1;
var levels = hls.levels;
var levels = hls.levels,
loadLevel = hls.loadLevel,
minAutoLevel = hls.minAutoLevel,
maxAutoLevel = hls.maxAutoLevel;
var fragErrorType = (_data$frag = data.frag) == null ? void 0 : _data$frag.type;
var _ref = (_data$context2 = data.context) != null ? _data$context2 : {},
playlistErrorType = _ref.type,
playlistErrorGroupId = _ref.groupId;
for (var i = levels.length; i--;) {
var candidate = (i + hls.loadLevel) % levels.length;
if (candidate !== hls.loadLevel && levels[candidate].loadError === 0) {
var candidate = (i + loadLevel) % levels.length;
if (candidate !== loadLevel && candidate >= minAutoLevel && candidate <= maxAutoLevel && levels[candidate].loadError === 0) {
var levelCandidate = levels[candidate];
// Skip level switch if GAP tag is found in next level at same position
if (data.details === ErrorDetails.FRAG_GAP && data.frag) {
@ -9658,6 +9661,8 @@
} else {
logger.warn(data.details + " reached or exceeded max retry (" + retryCount + ")");
}
} else if ((errorAction == null ? void 0 : errorAction.action) === NetworkErrorAction.SendAlternateToPenaltyBox) {
this.state = State.WAITING_LEVEL;
} else {
this.state = State.ERROR;
}
@ -18027,14 +18032,7 @@
var startOffset = data.startOffset,
endOffset = data.endOffset;
if (startOffset === 0 && endOffset !== Number.POSITIVE_INFINITY) {
var currentTrackId = this.currentTrackId,
levels = this.levels;
if (!levels.length || !levels[currentTrackId] || !levels[currentTrackId].details) {
return;
}
var trackDetails = levels[currentTrackId].details;
var targetDuration = trackDetails.targetduration;
var endOffsetSubtitles = endOffset - targetDuration;
var endOffsetSubtitles = endOffset - 1;
if (endOffsetSubtitles <= 0) {
return;
}
@ -18228,17 +18226,14 @@
if (!levels.length || !track || !track.details) {
return;
}
// Expand range of subs loaded by one target-duration in either direction to make up for misaligned playlists
var trackDetails = track.details;
var targetDuration = trackDetails.targetduration;
var config = this.config;
var currentTime = this.getLoadPosition();
var bufferedInfo = BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId] || [], currentTime - targetDuration, config.maxBufferHole);
var bufferedInfo = BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId] || [], currentTime, config.maxBufferHole);
var targetBufferTime = bufferedInfo.end,
bufferLen = bufferedInfo.len;
var mainBufferInfo = this.getFwdBufferInfo(this.media, PlaylistLevelType.MAIN);
var maxBufLen = this.getMaxBufferLength(mainBufferInfo == null ? void 0 : mainBufferInfo.len) + targetDuration;
var trackDetails = track.details;
var maxBufLen = this.getMaxBufferLength(mainBufferInfo == null ? void 0 : mainBufferInfo.len) + trackDetails.levelTargetDuration;
if (bufferLen > maxBufLen) {
return;
}
@ -18248,8 +18243,9 @@
var foundFrag = null;
var fragPrevious = this.fragPrevious;
if (targetBufferTime < end) {
var maxFragLookUpTolerance = config.maxFragLookUpTolerance;
foundFrag = findFragmentByPTS(fragPrevious, fragments, Math.max(fragments[0].start, targetBufferTime), maxFragLookUpTolerance);
var tolerance = config.maxFragLookUpTolerance;
var lookupTolerance = targetBufferTime > end - tolerance ? 0 : tolerance;
foundFrag = findFragmentByPTS(fragPrevious, fragments, Math.max(fragments[0].start, targetBufferTime), lookupTolerance);
if (!foundFrag && fragPrevious && fragPrevious.start < fragments[0].start) {
foundFrag = fragments[0];
}
@ -18260,6 +18256,14 @@
return;
}
foundFrag = this.mapToInitFragWhenRequired(foundFrag);
if (foundFrag.sn !== 'initSegment') {
// Load earlier fragment in same discontinuity to make up for misaligned playlists and cues that extend beyond end of segment
var curSNIdx = foundFrag.sn - trackDetails.startSN;
var prevFrag = fragments[curSNIdx - 1];
if (prevFrag && prevFrag.cc === foundFrag.cc && this.fragmentTracker.getState(prevFrag) === FragmentState.NOT_LOADED) {
foundFrag = prevFrag;
}
}
if (this.fragmentTracker.getState(foundFrag) === FragmentState.NOT_LOADED) {
// only load if fragment is not loaded
this.loadFragment(foundFrag, track, targetBufferTime);
@ -21639,7 +21643,7 @@
// Uint8Array.prototype.reduce is not implemented in IE11
var vttLines = utf8ArrayToStr(new Uint8Array(vttByteArray)).trim().replace(LINEBREAKS, '\n').split('\n');
var cues = [];
var init90kHz = toMpegTsClockFromTimescale(initPTS.baseTime, initPTS.timescale);
var init90kHz = initPTS ? toMpegTsClockFromTimescale(initPTS.baseTime, initPTS.timescale) : 0;
var cueTime = '00:00.000';
var timestampMapMPEGTS = 0;
var timestampMapLOCAL = 0;
@ -21663,6 +21667,10 @@
}
}
if (webVttMpegTsMapOffset) {
if (!initPTS) {
parsingError = new Error('Missing initPTS for VTT MPEGTS');
return;
}
// If we have MPEGTS, offset = presentation time + discontinuity offset
cueOffset = webVttMpegTsMapOffset - vttCCs.presentationOffset;
}
@ -22153,7 +22161,7 @@
this.captionsTracks = {};
this.nonNativeCaptionsTracks = {};
this.textTracks = [];
this.unparsedVttFrags = this.unparsedVttFrags || [];
this.unparsedVttFrags = [];
this.initPTS = [];
if (this.cea608Parser1 && this.cea608Parser2) {
this.cea608Parser1.reset();
@ -22295,24 +22303,9 @@
_proto.onFragLoaded = function onFragLoaded(event, data) {
var frag = data.frag,
payload = data.payload;
var initPTS = this.initPTS,
unparsedVttFrags = this.unparsedVttFrags;
if (frag.type === PlaylistLevelType.SUBTITLE) {
// If fragment is subtitle type, parse as WebVTT.
if (payload.byteLength) {
// We need an initial synchronisation PTS. Store fragments as long as none has arrived.
if (!initPTS[frag.cc]) {
unparsedVttFrags.push(data);
if (initPTS.length) {
// finish unsuccessfully, otherwise the subtitle-stream-controller could be blocked from loading new frags.
this.hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, {
success: false,
frag: frag,
error: new Error('Missing initial subtitle PTS')
});
}
return;
}
var decryptData = frag.decryptdata;
// fragment after decryption has a stats object
var decrypted = ('stats' in data);
@ -22331,7 +22324,7 @@
if (trackPlaylistMedia && trackPlaylistMedia.textCodec === IMSC1_CODEC) {
this._parseIMSC1(frag, payload);
} else {
this._parseVTTs(frag, payload, vttCCs);
this._parseVTTs(data);
}
}
} else {
@ -22362,22 +22355,40 @@
});
});
};
_proto._parseVTTs = function _parseVTTs(frag, payload, vttCCs) {
_proto._parseVTTs = function _parseVTTs(data) {
var _frag$initSegment,
_this5 = this;
var frag = data.frag,
payload = data.payload;
// We need an initial synchronisation PTS. Store fragments as long as none has arrived
var initPTS = this.initPTS,
unparsedVttFrags = this.unparsedVttFrags;
var maxAvCC = initPTS.length - 1;
if (!initPTS[frag.cc] && maxAvCC === -1) {
unparsedVttFrags.push(data);
return;
}
var hls = this.hls;
// Parse the WebVTT file contents.
var payloadWebVTT = (_frag$initSegment = frag.initSegment) != null && _frag$initSegment.data ? appendUint8Array(frag.initSegment.data, new Uint8Array(payload)) : payload;
parseWebVTT(payloadWebVTT, this.initPTS[frag.cc], vttCCs, frag.cc, frag.start, function (cues) {
parseWebVTT(payloadWebVTT, this.initPTS[frag.cc], this.vttCCs, frag.cc, frag.start, function (cues) {
_this5._appendCues(cues, frag.level);
hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, {
success: true,
frag: frag
});
}, function (error) {
_this5._fallbackToIMSC1(frag, payload);
var missingInitPTS = error.message === 'Missing initPTS for VTT MPEGTS';
if (missingInitPTS) {
unparsedVttFrags.push(data);
} else {
_this5._fallbackToIMSC1(frag, payload);
}
// Something went wrong while parsing. Trigger event with success false.
logger.log("Failed to parse VTT cue: " + error);
if (missingInitPTS && maxAvCC > frag.cc) {
return;
}
hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, {
success: false,
frag: frag,
@ -22428,10 +22439,6 @@
_proto.onFragDecrypted = function onFragDecrypted(event, data) {
var frag = data.frag;
if (frag.type === PlaylistLevelType.SUBTITLE) {
if (!this.initPTS[frag.cc]) {
this.unparsedVttFrags.push(data);
return;
}
this.onFragLoaded(Events.FRAG_LOADED, data);
}
};
@ -24622,6 +24629,7 @@
var stats = this.stats;
stats.loading.first = 0;
stats.loaded = 0;
stats.aborted = false;
var xhrSetup = this.xhrSetup;
if (xhrSetup) {
Promise.resolve().then(function () {
@ -26252,7 +26260,7 @@
* Get the video-dev/hls.js package version.
*/
function get() {
return "1.4.5";
return "1.4.7";
}
}, {
key: "Events",

File diff suppressed because one or more lines are too long

View file

@ -508,7 +508,7 @@
// Some browsers don't allow to use bind on console object anyway
// fallback to default if needed
try {
exportedLogger.log("Debug logs enabled for \"" + id + "\" in hls.js version " + "1.4.5");
exportedLogger.log("Debug logs enabled for \"" + id + "\" in hls.js version " + "1.4.7");
} catch (e) {
exportedLogger = fakeLogger;
}
@ -5264,14 +5264,17 @@
var _data$frag, _data$context2;
// Search for next level to retry
var nextLevel = -1;
var levels = hls.levels;
var levels = hls.levels,
loadLevel = hls.loadLevel,
minAutoLevel = hls.minAutoLevel,
maxAutoLevel = hls.maxAutoLevel;
var fragErrorType = (_data$frag = data.frag) == null ? void 0 : _data$frag.type;
var _ref = (_data$context2 = data.context) != null ? _data$context2 : {},
playlistErrorType = _ref.type,
playlistErrorGroupId = _ref.groupId;
for (var i = levels.length; i--;) {
var candidate = (i + hls.loadLevel) % levels.length;
if (candidate !== hls.loadLevel && levels[candidate].loadError === 0) {
var candidate = (i + loadLevel) % levels.length;
if (candidate !== loadLevel && candidate >= minAutoLevel && candidate <= maxAutoLevel && levels[candidate].loadError === 0) {
var levelCandidate = levels[candidate];
// Skip level switch if GAP tag is found in next level at same position
if (data.details === ErrorDetails.FRAG_GAP && data.frag) {
@ -9111,6 +9114,8 @@
} else {
logger.warn(data.details + " reached or exceeded max retry (" + retryCount + ")");
}
} else if ((errorAction == null ? void 0 : errorAction.action) === NetworkErrorAction.SendAlternateToPenaltyBox) {
this.state = State.WAITING_LEVEL;
} else {
this.state = State.ERROR;
}
@ -17641,6 +17646,7 @@
var stats = this.stats;
stats.loading.first = 0;
stats.loaded = 0;
stats.aborted = false;
var xhrSetup = this.xhrSetup;
if (xhrSetup) {
Promise.resolve().then(function () {
@ -19225,7 +19231,7 @@
* Get the video-dev/hls.js package version.
*/
function get() {
return "1.4.5";
return "1.4.7";
}
}, {
key: "Events",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -402,7 +402,7 @@ function enableLogs(debugConfig, id) {
// Some browsers don't allow to use bind on console object anyway
// fallback to default if needed
try {
exportedLogger.log(`Debug logs enabled for "${id}" in hls.js version ${"1.4.5"}`);
exportedLogger.log(`Debug logs enabled for "${id}" in hls.js version ${"1.4.7"}`);
} catch (e) {
exportedLogger = fakeLogger;
}
@ -5019,15 +5019,20 @@ class ErrorController {
var _data$frag, _data$context2;
// Search for next level to retry
let nextLevel = -1;
const levels = hls.levels;
const {
levels,
loadLevel,
minAutoLevel,
maxAutoLevel
} = hls;
const fragErrorType = (_data$frag = data.frag) == null ? void 0 : _data$frag.type;
const {
type: playlistErrorType,
groupId: playlistErrorGroupId
} = (_data$context2 = data.context) != null ? _data$context2 : {};
for (let i = levels.length; i--;) {
const candidate = (i + hls.loadLevel) % levels.length;
if (candidate !== hls.loadLevel && levels[candidate].loadError === 0) {
const candidate = (i + loadLevel) % levels.length;
if (candidate !== loadLevel && candidate >= minAutoLevel && candidate <= maxAutoLevel && levels[candidate].loadError === 0) {
const levelCandidate = levels[candidate];
// Skip level switch if GAP tag is found in next level at same position
if (data.details === ErrorDetails.FRAG_GAP && data.frag) {
@ -8829,6 +8834,8 @@ class BaseStreamController extends TaskLoop {
} else {
logger.warn(`${data.details} reached or exceeded max retry (${retryCount})`);
}
} else if ((errorAction == null ? void 0 : errorAction.action) === NetworkErrorAction.SendAlternateToPenaltyBox) {
this.state = State.WAITING_LEVEL;
} else {
this.state = State.ERROR;
}
@ -17247,6 +17254,7 @@ class XhrLoader {
const stats = this.stats;
stats.loading.first = 0;
stats.loaded = 0;
stats.aborted = false;
const xhrSetup = this.xhrSetup;
if (xhrSetup) {
Promise.resolve().then(() => {
@ -18074,7 +18082,7 @@ class Hls {
* Get the video-dev/hls.js package version.
*/
static get version() {
return "1.4.5";
return "1.4.7";
}
/**

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

112
node_modules/hls.js/dist/hls.mjs generated vendored
View file

@ -402,7 +402,7 @@ function enableLogs(debugConfig, id) {
// Some browsers don't allow to use bind on console object anyway
// fallback to default if needed
try {
exportedLogger.log(`Debug logs enabled for "${id}" in hls.js version ${"1.4.5"}`);
exportedLogger.log(`Debug logs enabled for "${id}" in hls.js version ${"1.4.7"}`);
} catch (e) {
exportedLogger = fakeLogger;
}
@ -5486,15 +5486,20 @@ class ErrorController {
var _data$frag, _data$context2;
// Search for next level to retry
let nextLevel = -1;
const levels = hls.levels;
const {
levels,
loadLevel,
minAutoLevel,
maxAutoLevel
} = hls;
const fragErrorType = (_data$frag = data.frag) == null ? void 0 : _data$frag.type;
const {
type: playlistErrorType,
groupId: playlistErrorGroupId
} = (_data$context2 = data.context) != null ? _data$context2 : {};
for (let i = levels.length; i--;) {
const candidate = (i + hls.loadLevel) % levels.length;
if (candidate !== hls.loadLevel && levels[candidate].loadError === 0) {
const candidate = (i + loadLevel) % levels.length;
if (candidate !== loadLevel && candidate >= minAutoLevel && candidate <= maxAutoLevel && levels[candidate].loadError === 0) {
const levelCandidate = levels[candidate];
// Skip level switch if GAP tag is found in next level at same position
if (data.details === ErrorDetails.FRAG_GAP && data.frag) {
@ -9334,6 +9339,8 @@ class BaseStreamController extends TaskLoop {
} else {
logger.warn(`${data.details} reached or exceeded max retry (${retryCount})`);
}
} else if ((errorAction == null ? void 0 : errorAction.action) === NetworkErrorAction.SendAlternateToPenaltyBox) {
this.state = State.WAITING_LEVEL;
} else {
this.state = State.ERROR;
}
@ -17600,16 +17607,7 @@ class SubtitleStreamController extends BaseStreamController {
endOffset
} = data;
if (startOffset === 0 && endOffset !== Number.POSITIVE_INFINITY) {
const {
currentTrackId,
levels
} = this;
if (!levels.length || !levels[currentTrackId] || !levels[currentTrackId].details) {
return;
}
const trackDetails = levels[currentTrackId].details;
const targetDuration = trackDetails.targetduration;
const endOffsetSubtitles = endOffset - targetDuration;
const endOffsetSubtitles = endOffset - 1;
if (endOffsetSubtitles <= 0) {
return;
}
@ -17805,21 +17803,18 @@ class SubtitleStreamController extends BaseStreamController {
if (!levels.length || !track || !track.details) {
return;
}
// Expand range of subs loaded by one target-duration in either direction to make up for misaligned playlists
const trackDetails = track.details;
const targetDuration = trackDetails.targetduration;
const {
config
} = this;
const currentTime = this.getLoadPosition();
const bufferedInfo = BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId] || [], currentTime - targetDuration, config.maxBufferHole);
const bufferedInfo = BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId] || [], currentTime, config.maxBufferHole);
const {
end: targetBufferTime,
len: bufferLen
} = bufferedInfo;
const mainBufferInfo = this.getFwdBufferInfo(this.media, PlaylistLevelType.MAIN);
const maxBufLen = this.getMaxBufferLength(mainBufferInfo == null ? void 0 : mainBufferInfo.len) + targetDuration;
const trackDetails = track.details;
const maxBufLen = this.getMaxBufferLength(mainBufferInfo == null ? void 0 : mainBufferInfo.len) + trackDetails.levelTargetDuration;
if (bufferLen > maxBufLen) {
return;
}
@ -17829,10 +17824,9 @@ class SubtitleStreamController extends BaseStreamController {
let foundFrag = null;
const fragPrevious = this.fragPrevious;
if (targetBufferTime < end) {
const {
maxFragLookUpTolerance
} = config;
foundFrag = findFragmentByPTS(fragPrevious, fragments, Math.max(fragments[0].start, targetBufferTime), maxFragLookUpTolerance);
const tolerance = config.maxFragLookUpTolerance;
const lookupTolerance = targetBufferTime > end - tolerance ? 0 : tolerance;
foundFrag = findFragmentByPTS(fragPrevious, fragments, Math.max(fragments[0].start, targetBufferTime), lookupTolerance);
if (!foundFrag && fragPrevious && fragPrevious.start < fragments[0].start) {
foundFrag = fragments[0];
}
@ -17843,6 +17837,14 @@ class SubtitleStreamController extends BaseStreamController {
return;
}
foundFrag = this.mapToInitFragWhenRequired(foundFrag);
if (foundFrag.sn !== 'initSegment') {
// Load earlier fragment in same discontinuity to make up for misaligned playlists and cues that extend beyond end of segment
const curSNIdx = foundFrag.sn - trackDetails.startSN;
const prevFrag = fragments[curSNIdx - 1];
if (prevFrag && prevFrag.cc === foundFrag.cc && this.fragmentTracker.getState(prevFrag) === FragmentState.NOT_LOADED) {
foundFrag = prevFrag;
}
}
if (this.fragmentTracker.getState(foundFrag) === FragmentState.NOT_LOADED) {
// only load if fragment is not loaded
this.loadFragment(foundFrag, track, targetBufferTime);
@ -21186,7 +21188,7 @@ function parseWebVTT(vttByteArray, initPTS, vttCCs, cc, timeOffset, callBack, er
// Uint8Array.prototype.reduce is not implemented in IE11
const vttLines = utf8ArrayToStr(new Uint8Array(vttByteArray)).trim().replace(LINEBREAKS, '\n').split('\n');
const cues = [];
const init90kHz = toMpegTsClockFromTimescale(initPTS.baseTime, initPTS.timescale);
const init90kHz = initPTS ? toMpegTsClockFromTimescale(initPTS.baseTime, initPTS.timescale) : 0;
let cueTime = '00:00.000';
let timestampMapMPEGTS = 0;
let timestampMapLOCAL = 0;
@ -21210,6 +21212,10 @@ function parseWebVTT(vttByteArray, initPTS, vttCCs, cc, timeOffset, callBack, er
}
}
if (webVttMpegTsMapOffset) {
if (!initPTS) {
parsingError = new Error('Missing initPTS for VTT MPEGTS');
return;
}
// If we have MPEGTS, offset = presentation time + discontinuity offset
cueOffset = webVttMpegTsMapOffset - vttCCs.presentationOffset;
}
@ -21705,7 +21711,7 @@ class TimelineController {
this.captionsTracks = {};
this.nonNativeCaptionsTracks = {};
this.textTracks = [];
this.unparsedVttFrags = this.unparsedVttFrags || [];
this.unparsedVttFrags = [];
this.initPTS = [];
if (this.cea608Parser1 && this.cea608Parser2) {
this.cea608Parser1.reset();
@ -21849,26 +21855,9 @@ class TimelineController {
frag,
payload
} = data;
const {
initPTS,
unparsedVttFrags
} = this;
if (frag.type === PlaylistLevelType.SUBTITLE) {
// If fragment is subtitle type, parse as WebVTT.
if (payload.byteLength) {
// We need an initial synchronisation PTS. Store fragments as long as none has arrived.
if (!initPTS[frag.cc]) {
unparsedVttFrags.push(data);
if (initPTS.length) {
// finish unsuccessfully, otherwise the subtitle-stream-controller could be blocked from loading new frags.
this.hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, {
success: false,
frag,
error: new Error('Missing initial subtitle PTS')
});
}
return;
}
const decryptData = frag.decryptdata;
// fragment after decryption has a stats object
const decrypted = ('stats' in data);
@ -21887,7 +21876,7 @@ class TimelineController {
if (trackPlaylistMedia && trackPlaylistMedia.textCodec === IMSC1_CODEC) {
this._parseIMSC1(frag, payload);
} else {
this._parseVTTs(frag, payload, vttCCs);
this._parseVTTs(data);
}
}
} else {
@ -21917,21 +21906,43 @@ class TimelineController {
});
});
}
_parseVTTs(frag, payload, vttCCs) {
_parseVTTs(data) {
var _frag$initSegment;
const {
frag,
payload
} = data;
// We need an initial synchronisation PTS. Store fragments as long as none has arrived
const {
initPTS,
unparsedVttFrags
} = this;
const maxAvCC = initPTS.length - 1;
if (!initPTS[frag.cc] && maxAvCC === -1) {
unparsedVttFrags.push(data);
return;
}
const hls = this.hls;
// Parse the WebVTT file contents.
const payloadWebVTT = (_frag$initSegment = frag.initSegment) != null && _frag$initSegment.data ? appendUint8Array(frag.initSegment.data, new Uint8Array(payload)) : payload;
parseWebVTT(payloadWebVTT, this.initPTS[frag.cc], vttCCs, frag.cc, frag.start, cues => {
parseWebVTT(payloadWebVTT, this.initPTS[frag.cc], this.vttCCs, frag.cc, frag.start, cues => {
this._appendCues(cues, frag.level);
hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, {
success: true,
frag: frag
});
}, error => {
this._fallbackToIMSC1(frag, payload);
const missingInitPTS = error.message === 'Missing initPTS for VTT MPEGTS';
if (missingInitPTS) {
unparsedVttFrags.push(data);
} else {
this._fallbackToIMSC1(frag, payload);
}
// Something went wrong while parsing. Trigger event with success false.
logger.log(`Failed to parse VTT cue: ${error}`);
if (missingInitPTS && maxAvCC > frag.cc) {
return;
}
hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, {
success: false,
frag: frag,
@ -21981,10 +21992,6 @@ class TimelineController {
frag
} = data;
if (frag.type === PlaylistLevelType.SUBTITLE) {
if (!this.initPTS[frag.cc]) {
this.unparsedVttFrags.push(data);
return;
}
this.onFragLoaded(Events.FRAG_LOADED, data);
}
}
@ -24117,6 +24124,7 @@ class XhrLoader {
const stats = this.stats;
stats.loading.first = 0;
stats.loaded = 0;
stats.aborted = false;
const xhrSetup = this.xhrSetup;
if (xhrSetup) {
Promise.resolve().then(() => {
@ -24988,7 +24996,7 @@ class Hls {
* Get the video-dev/hls.js package version.
*/
static get version() {
return "1.4.5";
return "1.4.7";
}
/**

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
node_modules/hls.js/package.json generated vendored
View file

@ -129,5 +129,5 @@
"url-toolkit": "2.2.5",
"wrangler": "2.20.0"
},
"version": "1.4.5"
"version": "1.4.7"
}

View file

@ -1530,6 +1530,10 @@ export default class BaseStreamController
`${data.details} reached or exceeded max retry (${retryCount})`
);
}
} else if (
errorAction?.action === NetworkErrorAction.SendAlternateToPenaltyBox
) {
this.state = State.WAITING_LEVEL;
} else {
this.state = State.ERROR;
}

View file

@ -330,14 +330,16 @@ export default class ErrorController implements NetworkComponentAPI {
if (hls.autoLevelEnabled) {
// Search for next level to retry
let nextLevel = -1;
const levels = hls.levels;
const { levels, loadLevel, minAutoLevel, maxAutoLevel } = hls;
const fragErrorType = data.frag?.type;
const { type: playlistErrorType, groupId: playlistErrorGroupId } =
data.context ?? {};
for (let i = levels.length; i--; ) {
const candidate = (i + hls.loadLevel) % levels.length;
const candidate = (i + loadLevel) % levels.length;
if (
candidate !== hls.loadLevel &&
candidate !== loadLevel &&
candidate >= minAutoLevel &&
candidate <= maxAutoLevel &&
levels[candidate].loadError === 0
) {
const levelCandidate = levels[candidate];

View file

@ -165,17 +165,7 @@ export class SubtitleStreamController
onBufferFlushing(event: Events.BUFFER_FLUSHING, data: BufferFlushingData) {
const { startOffset, endOffset } = data;
if (startOffset === 0 && endOffset !== Number.POSITIVE_INFINITY) {
const { currentTrackId, levels } = this;
if (
!levels.length ||
!levels[currentTrackId] ||
!levels[currentTrackId].details
) {
return;
}
const trackDetails = levels[currentTrackId].details as LevelDetails;
const targetDuration = trackDetails.targetduration;
const endOffsetSubtitles = endOffset - targetDuration;
const endOffsetSubtitles = endOffset - 1;
if (endOffsetSubtitles <= 0) {
return;
}
@ -408,15 +398,11 @@ export class SubtitleStreamController
if (!levels.length || !track || !track.details) {
return;
}
// Expand range of subs loaded by one target-duration in either direction to make up for misaligned playlists
const trackDetails = track.details as LevelDetails;
const targetDuration = trackDetails.targetduration;
const { config } = this;
const currentTime = this.getLoadPosition();
const bufferedInfo = BufferHelper.bufferedInfo(
this.tracksBuffered[this.currentTrackId] || [],
currentTime - targetDuration,
currentTime,
config.maxBufferHole
);
const { end: targetBufferTime, len: bufferLen } = bufferedInfo;
@ -425,8 +411,10 @@ export class SubtitleStreamController
this.media,
PlaylistLevelType.MAIN
);
const trackDetails = track.details as LevelDetails;
const maxBufLen =
this.getMaxBufferLength(mainBufferInfo?.len) + targetDuration;
this.getMaxBufferLength(mainBufferInfo?.len) +
trackDetails.levelTargetDuration;
if (bufferLen > maxBufLen) {
return;
@ -438,12 +426,14 @@ export class SubtitleStreamController
let foundFrag: Fragment | null = null;
const fragPrevious = this.fragPrevious;
if (targetBufferTime < end) {
const { maxFragLookUpTolerance } = config;
const tolerance = config.maxFragLookUpTolerance;
const lookupTolerance =
targetBufferTime > end - tolerance ? 0 : tolerance;
foundFrag = findFragmentByPTS(
fragPrevious,
fragments,
Math.max(fragments[0].start, targetBufferTime),
maxFragLookUpTolerance
lookupTolerance
);
if (
!foundFrag &&
@ -458,8 +448,19 @@ export class SubtitleStreamController
if (!foundFrag) {
return;
}
foundFrag = this.mapToInitFragWhenRequired(foundFrag) as Fragment;
if (foundFrag.sn !== 'initSegment') {
// Load earlier fragment in same discontinuity to make up for misaligned playlists and cues that extend beyond end of segment
const curSNIdx = foundFrag.sn - trackDetails.startSN;
const prevFrag = fragments[curSNIdx - 1];
if (
prevFrag &&
prevFrag.cc === foundFrag.cc &&
this.fragmentTracker.getState(prevFrag) === FragmentState.NOT_LOADED
) {
foundFrag = prevFrag;
}
}
if (
this.fragmentTracker.getState(foundFrag) === FragmentState.NOT_LOADED
) {

View file

@ -304,7 +304,7 @@ export class TimelineController implements ComponentAPI {
this.captionsTracks = {};
this.nonNativeCaptionsTracks = {};
this.textTracks = [];
this.unparsedVttFrags = this.unparsedVttFrags || [];
this.unparsedVttFrags = [];
this.initPTS = [];
if (this.cea608Parser1 && this.cea608Parser2) {
this.cea608Parser1.reset();
@ -477,24 +477,9 @@ export class TimelineController implements ComponentAPI {
data: FragDecryptedData | FragLoadedData
) {
const { frag, payload } = data;
const { initPTS, unparsedVttFrags } = this;
if (frag.type === PlaylistLevelType.SUBTITLE) {
// If fragment is subtitle type, parse as WebVTT.
if (payload.byteLength) {
// We need an initial synchronisation PTS. Store fragments as long as none has arrived.
if (!initPTS[frag.cc]) {
unparsedVttFrags.push(data);
if (initPTS.length) {
// finish unsuccessfully, otherwise the subtitle-stream-controller could be blocked from loading new frags.
this.hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, {
success: false,
frag,
error: new Error('Missing initial subtitle PTS'),
});
}
return;
}
const decryptData = frag.decryptdata;
// fragment after decryption has a stats object
const decrypted = 'stats' in data;
@ -516,7 +501,7 @@ export class TimelineController implements ComponentAPI {
) {
this._parseIMSC1(frag, payload);
} else {
this._parseVTTs(frag, payload, vttCCs);
this._parseVTTs(data);
}
}
} else {
@ -553,7 +538,16 @@ export class TimelineController implements ComponentAPI {
);
}
private _parseVTTs(frag: Fragment, payload: ArrayBuffer, vttCCs: any) {
private _parseVTTs(data: FragDecryptedData | FragLoadedData) {
const { frag, payload } = data;
// We need an initial synchronisation PTS. Store fragments as long as none has arrived
const { initPTS, unparsedVttFrags } = this;
const maxAvCC = initPTS.length - 1;
if (!initPTS[frag.cc] && maxAvCC === -1) {
unparsedVttFrags.push(data);
return;
}
const hls = this.hls;
// Parse the WebVTT file contents.
const payloadWebVTT = frag.initSegment?.data
@ -562,7 +556,7 @@ export class TimelineController implements ComponentAPI {
parseWebVTT(
payloadWebVTT,
this.initPTS[frag.cc],
vttCCs,
this.vttCCs,
frag.cc,
frag.start,
(cues) => {
@ -573,9 +567,18 @@ export class TimelineController implements ComponentAPI {
});
},
(error) => {
this._fallbackToIMSC1(frag, payload);
const missingInitPTS =
error.message === 'Missing initPTS for VTT MPEGTS';
if (missingInitPTS) {
unparsedVttFrags.push(data);
} else {
this._fallbackToIMSC1(frag, payload);
}
// Something went wrong while parsing. Trigger event with success false.
logger.log(`Failed to parse VTT cue: ${error}`);
if (missingInitPTS && maxAvCC > frag.cc) {
return;
}
hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, {
success: false,
frag: frag,
@ -631,10 +634,6 @@ export class TimelineController implements ComponentAPI {
) {
const { frag } = data;
if (frag.type === PlaylistLevelType.SUBTITLE) {
if (!this.initPTS[frag.cc]) {
this.unparsedVttFrags.push(data as unknown as FragLoadedData);
return;
}
this.onFragLoaded(Events.FRAG_LOADED, data as unknown as FragLoadedData);
}
}

View file

@ -92,7 +92,7 @@ const calculateOffset = function (vttCCs: VTTCCs, cc, presentationTime) {
export function parseWebVTT(
vttByteArray: ArrayBuffer,
initPTS: RationalTimestamp,
initPTS: RationalTimestamp | undefined,
vttCCs: VTTCCs,
cc: number,
timeOffset: number,
@ -107,10 +107,9 @@ export function parseWebVTT(
.replace(LINEBREAKS, '\n')
.split('\n');
const cues: VTTCue[] = [];
const init90kHz = toMpegTsClockFromTimescale(
initPTS.baseTime,
initPTS.timescale
);
const init90kHz = initPTS
? toMpegTsClockFromTimescale(initPTS.baseTime, initPTS.timescale)
: 0;
let cueTime = '00:00.000';
let timestampMapMPEGTS = 0;
let timestampMapLOCAL = 0;
@ -134,8 +133,11 @@ export function parseWebVTT(
calculateOffset(vttCCs, cc, webVttMpegTsMapOffset);
}
}
if (webVttMpegTsMapOffset) {
if (!initPTS) {
parsingError = new Error('Missing initPTS for VTT MPEGTS');
return;
}
// If we have MPEGTS, offset = presentation time + discontinuity offset
cueOffset = webVttMpegTsMapOffset - vttCCs.presentationOffset;
}

View file

@ -86,6 +86,7 @@ class XhrLoader implements Loader<LoaderContext> {
const stats = this.stats;
stats.loading.first = 0;
stats.loaded = 0;
stats.aborted = false;
const xhrSetup = this.xhrSetup;
if (xhrSetup) {

View file

@ -1531,7 +1531,7 @@ if (!class_exists('Video')) {
if(!empty($max_duration_in_seconds)){
$max_duration_in_seconds = intval($max_duration_in_seconds);
$sql .= " AND duration_in_seconds <= {$max_duration_in_seconds} ";
$sql .= " AND duration_in_seconds IS NOT NULL AND duration_in_seconds <= {$max_duration_in_seconds} AND duration_in_seconds > 0 ";
}
$sql .= AVideoPlugin::getVideoWhereClause();
@ -2014,7 +2014,7 @@ if (!class_exists('Video')) {
if(!empty($max_duration_in_seconds)){
$max_duration_in_seconds = intval($max_duration_in_seconds);
$sql .= " AND duration_in_seconds <= {$max_duration_in_seconds} ";
$sql .= " AND duration_in_seconds IS NOT NULL AND duration_in_seconds <= {$max_duration_in_seconds} AND duration_in_seconds > 0 ";
}
$sql .= AVideoPlugin::getVideoWhereClause();
@ -2213,7 +2213,7 @@ if (!class_exists('Video')) {
if(!empty($max_duration_in_seconds)){
$max_duration_in_seconds = intval($max_duration_in_seconds);
$sql .= " AND duration_in_seconds <= {$max_duration_in_seconds} ";
$sql .= " AND duration_in_seconds IS NOT NULL AND duration_in_seconds <= {$max_duration_in_seconds} AND duration_in_seconds > 0 ";
}
$sql .= AVideoPlugin::getVideoWhereClause();

20
package-lock.json generated
View file

@ -14,6 +14,7 @@
"dexie": "^3.2.4",
"dom-walk": "^0.1.2",
"flickity": "^3.0.0",
"flickity-bg-lazyload": "^2.0.0",
"fontawesome-free": "^1.0.4",
"hls.js": "^1.4.7",
"infinite-scroll": "^4.0.1",
@ -761,6 +762,17 @@
"unidragger": "^3.0.0"
}
},
"node_modules/flickity-bg-lazyload": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/flickity-bg-lazyload/-/flickity-bg-lazyload-2.0.0.tgz",
"integrity": "sha512-il5f8gi0GHNGv0mU+rpEfEAnv1VBpYYRKMVsgmFR5hblBlhT6VaQltKTjc8irTgU8lNOdEuaGavW/AE0QzjSMg==",
"dependencies": {
"fizzy-ui-utils": "^3.0.0"
},
"peerDependencies": {
"flickity": "^3.0.0"
}
},
"node_modules/fontawesome-free": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/fontawesome-free/-/fontawesome-free-1.0.4.tgz",
@ -2722,6 +2734,14 @@
"unidragger": "^3.0.0"
}
},
"flickity-bg-lazyload": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/flickity-bg-lazyload/-/flickity-bg-lazyload-2.0.0.tgz",
"integrity": "sha512-il5f8gi0GHNGv0mU+rpEfEAnv1VBpYYRKMVsgmFR5hblBlhT6VaQltKTjc8irTgU8lNOdEuaGavW/AE0QzjSMg==",
"requires": {
"fizzy-ui-utils": "^3.0.0"
}
},
"fontawesome-free": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/fontawesome-free/-/fontawesome-free-1.0.4.tgz",

View file

@ -9,6 +9,7 @@
"dexie": "^3.2.4",
"dom-walk": "^0.1.2",
"flickity": "^3.0.0",
"flickity-bg-lazyload": "^2.0.0",
"fontawesome-free": "^1.0.4",
"hls.js": "^1.4.7",
"infinite-scroll": "^4.0.1",

View file

@ -156,11 +156,14 @@ if ($removeAnimation) {
function populateCarouselPlayer(video) {
var $carouselPlayer = $('#ShortsPlayer');
var newCarouselCell = $('<div>').addClass('carousel-cell');
var newCarouselCellContent = $('<div>').addClass('carousel-cell-content').attr('data-video-url', video.videoLink).css('background-image', 'url(' + video.images.posterLandscapeThumbs + ')');
var newCarouselCellContent = $('<div>')
.addClass('carousel-cell-content')
.attr('data-flickity-bg-lazyload', video.images.poster);
newCarouselCellContent.append($('<strong>').text(video.title));
newCarouselCell.append(newCarouselCellContent);
$carouselPlayer.flickity('append', newCarouselCell);
}
var isSettling = false;
var timeoutId = null;
@ -172,6 +175,7 @@ if ($removeAnimation) {
contain: true,
pageDots: false,
initialIndex: initialIndex,
bgLazyLoad: true
});
$carouselPlayer.on('settle.flickity', function(event, index) {

View file

@ -64,6 +64,7 @@
}
</style>
<script src="<?php echo getURL('node_modules/flickity/dist/flickity.pkgd.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo getURL('node_modules/flickity-bg-lazyload/bg-lazyload.js'); ?>" type="text/javascript"></script>
<h3 class="galleryTitle"><i class="fas fa-layer-group"></i> <?php echo __('Shorts'); ?></h3>
<!-- Flickity HTML init -->
@ -97,13 +98,16 @@
}
shortVideos.push(video);
populateCarouselPlayer(video);
imageUrl = video.images.posterLandscapeThumbs;
imageUrl = video.images.poster;
var newCarouselCell = $('<div>').addClass('carousel-cell');
var newCarouselCellContent = $('<div>').addClass('carousel-cell-content').css('background-image', 'url(' + imageUrl + ')');
var newCarouselCellContent = $('<div>')
.addClass('carousel-cell-content')
.attr('data-flickity-bg-lazyload', imageUrl);
newCarouselCellContent.append($('<strong>').text(video.title));
newCarouselCell.append(newCarouselCellContent);
// append the new cell to the carousel
$carousel.flickity('append', newCarouselCell);
}
isLoadingShorts = false;
@ -115,7 +119,8 @@
var $carousel = $('#Shorts');
$carousel.flickity({
groupCells: true
groupCells: true,
bgLazyLoad: true
});
$carousel.on('scroll.flickity', function(event, progress) {