@faintlines/video-player
Advanced tools
Comparing version 2.6.6 to 2.6.7
@@ -98,4 +98,4 @@ import { objectSpread2 as _objectSpread2, extends as _extends } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
var useHls = shouldUseHLS(url, config); | ||
var hlsOptions = config.hlsOptions, | ||
attributes = config.attributes; | ||
var hlsOptions = useObjectMemo(config.hlsOptions); | ||
var attributes = config.attributes; | ||
var handlePlay = useCallback(function () { | ||
@@ -102,0 +102,0 @@ var st = stRef.current; |
@@ -0,1 +1,4 @@ | ||
import { defineProperty as _defineProperty } from '../_virtual/_rollupPluginBabelHelpers.js'; | ||
import { Hls } from '../node_modules/.pnpm/hls.js@1.5.13/node_modules/hls.js/dist/hls.light.mjs.js'; | ||
var HlsErrorType = { | ||
@@ -20,20 +23,22 @@ // Errors automatically handled by hls.js. No action required. | ||
response = _ref.response; | ||
if ((NON_RECOVERABLE_ERRORS[type] || {})[details]) { | ||
return HlsErrorType.NON_RECOVERABLE; | ||
} | ||
if (fatal === false) { | ||
return HlsErrorType.AUTO_RECOVERABLE; | ||
} | ||
if ((NON_RECOVERABLE_ERRORS[type] || {})[details]) { | ||
if (type === Hls.ErrorTypes.NETWORK_ERROR && (response === null || response === void 0 ? void 0 : response.code) === 404) { | ||
return HlsErrorType.NON_RECOVERABLE; | ||
} | ||
if (type === "networkError" && (response === null || response === void 0 ? void 0 : response.code) === 404) { | ||
return HlsErrorType.NON_RECOVERABLE; | ||
} | ||
return HlsErrorType.RETRYABLE; | ||
} | ||
var NON_RECOVERABLE_ERRORS = { | ||
mediaError: { | ||
manifestIncompatibleCodecsError: true | ||
} | ||
}; | ||
var NON_RECOVERABLE_ERRORS = _defineProperty(_defineProperty({}, Hls.ErrorTypes.MEDIA_ERROR, { | ||
manifestIncompatibleCodecsError: true, | ||
// fragParsingError is marked as fatal=false, but it causes an infinite loading loop, so treat it as fatal | ||
fragParsingError: true | ||
}), Hls.ErrorTypes.NETWORK_ERROR, { | ||
manifestParsingError: true | ||
}); | ||
export { HlsErrorType, classifyHlsError }; | ||
//# sourceMappingURL=hlsErrorClassifier.js.map |
@@ -14,6 +14,2 @@ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
_excluded2 = ["playerRef"]; | ||
// A session-persistent list of unplayable HLS files, sharable by all VideoPlayer instances. | ||
var UNPLAYABLE_HLS_URLS = {}; // { url: true } | ||
var TRANSPARENT_PIXEL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"; | ||
@@ -67,2 +63,6 @@ var VideoPlayer = /*#__PURE__*/forwardRef(function (_ref, ref) { | ||
setRetryAttempt = _useState4[1]; | ||
var _useState5 = useState(null), | ||
_useState6 = _slicedToArray(_useState5, 2), | ||
hlsFailedUrl = _useState6[0], | ||
setHlsFailedUrl = _useState6[1]; | ||
var playerRef = useRef(); | ||
@@ -80,3 +80,3 @@ var loopRangeRef = useRef(loopRange); | ||
fileUrl: (urlObj === null || urlObj === void 0 ? void 0 : urlObj.file) || fileUrl | ||
}), | ||
}, hlsFailedUrl), | ||
_selectVideoUrl2 = _slicedToArray(_selectVideoUrl, 2), | ||
@@ -152,4 +152,4 @@ selectedUrl = _selectVideoUrl2[0], | ||
} | ||
handlePlayerError(evt, data, args, selectedUrl, autoRetry, setRetryAttempt, playerRef, onError, onRetryAttempt); | ||
}, [selectedUrl, onError, onRetryAttempt, autoRetry]); | ||
handlePlayerError(evt, data, args, selectedUrl, selectedUrlType, autoRetry, setRetryAttempt, setHlsFailedUrl, playerRef, onError, onRetryAttempt); | ||
}, [selectedUrl, selectedUrlType, onError, onRetryAttempt, autoRetry]); | ||
return /*#__PURE__*/React.createElement(Wrapper, { | ||
@@ -260,3 +260,5 @@ className: className, | ||
} | ||
function handlePlayerError(evt, data, args, selectedUrl, autoRetry, setRetryAttempt, playerRef, onError, onRetryAttempt) { | ||
function handlePlayerError(evt, | ||
// might be an HLS error event, or an Error instance. | ||
data, args, selectedUrl, selectedUrlType, autoRetry, setRetryAttempt, setHlsFailedUrl, playerRef, onError, onRetryAttempt) { | ||
switch (evt === null || evt === void 0 ? void 0 : evt.name) { | ||
@@ -278,5 +280,7 @@ // NotAllowedError means we tried playing the video before the user | ||
// "NotSupportedError: Failed to load because no supported source was found." | ||
// might be triggered when destroying a player (or switching the source) while the | ||
// video is still loading. | ||
// Examples: | ||
// NotSupportedError: Failed to load because no supported source was found. | ||
// NotSupportedError: The element has no supported sources. | ||
// This error might be triggered when destroying a player (or switching the source) while the | ||
// video is still loading, or in cases the device does not support the video encoding. | ||
case "NotSupportedError": | ||
@@ -286,2 +290,6 @@ if (!playerRef.current) { | ||
} | ||
if (selectedUrlType === "hls") { | ||
setHlsFailedUrl(selectedUrl); | ||
return; | ||
} | ||
break; | ||
@@ -294,7 +302,3 @@ } | ||
case HlsErrorType.NON_RECOVERABLE: | ||
UNPLAYABLE_HLS_URLS[selectedUrl] = true; | ||
playerRef.current = null; | ||
setRetryAttempt(function (x) { | ||
return x + 1; | ||
}); | ||
setHlsFailedUrl(selectedUrl); | ||
return; | ||
@@ -319,6 +323,6 @@ case HlsErrorType.AUTO_RECOVERABLE: | ||
} | ||
function selectVideoUrl(_ref4) { | ||
function selectVideoUrl(_ref4, hlsFailedUrl) { | ||
var hlsUrl = _ref4.hlsUrl, | ||
fileUrl = _ref4.fileUrl; | ||
if (hlsUrl && SUPPORTS_HLS && !UNPLAYABLE_HLS_URLS[hlsUrl]) { | ||
if (hlsUrl && SUPPORTS_HLS && hlsUrl !== hlsFailedUrl) { | ||
return [hlsUrl, "hls"]; | ||
@@ -325,0 +329,0 @@ } |
{ | ||
"name": "@faintlines/video-player", | ||
"version": "2.6.6", | ||
"version": "2.6.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "license": "UNLICENSED", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2516296
12749