@faintlines/video-player
Advanced tools
Comparing version 2.5.6 to 2.5.7
@@ -1,2 +0,2 @@ | ||
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, objectSpread2 as _objectSpread2 } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
import styles from './VideoPlayer.module.css.js'; | ||
@@ -149,48 +149,6 @@ import SubtitlesPlayer from './SubtitlesPlayer.js'; | ||
var errorHandler = useCallback(function (evt, data) { | ||
// NotAllowedError means we tried playing the video before the user | ||
// interacted with the page (see https://goo.gl/xX8pDD) | ||
// Try calling play() in a few more seconds | ||
if ((evt === null || evt === void 0 ? void 0 : evt.name) === "NotAllowedError") { | ||
setTimeout(function () { | ||
return tryPlaying(playerRef); | ||
}, 3000); | ||
return; | ||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
// The play request was aborted. For example: | ||
// "DOMException: The play() request was interrupted by a call to pause()" | ||
if ((evt === null || evt === void 0 ? void 0 : evt.name) === "AbortError") { | ||
return; | ||
} | ||
if (onError) { | ||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
onError.apply(void 0, [evt, data].concat(args)); | ||
} | ||
switch (classifyHlsError(evt, data)) { | ||
case HlsErrorType.NON_RECOVERABLE: | ||
UNPLAYABLE_HLS_URLS[selectedUrl] = true; | ||
playerRef.current = null; | ||
setRetryAttempt(function (x) { | ||
return x + 1; | ||
}); | ||
return; | ||
case HlsErrorType.AUTO_RECOVERABLE: | ||
// Ignore auto recoverable errors. They will be handled by hls.js | ||
return; | ||
case HlsErrorType.OTHER: | ||
default: | ||
if (autoRetry && !evt.defaultPrevented) { | ||
setTimeout(function () { | ||
playerRef.current = null; | ||
setRetryAttempt(function (x) { | ||
return x + 1; | ||
}); | ||
if (onRetryAttempt) { | ||
onRetryAttempt(); | ||
} | ||
}, 1000); | ||
} | ||
} | ||
handlePlayerError(evt, data, args, selectedUrl, autoRetry, setRetryAttempt, playerRef, onError, onRetryAttempt); | ||
}, [selectedUrl, onError, onRetryAttempt, autoRetry]); | ||
@@ -302,2 +260,56 @@ var providerProps = useMemo(function () { | ||
} | ||
function handlePlayerError(evt, data, args, selectedUrl, autoRetry, setRetryAttempt, playerRef, onError, onRetryAttempt) { | ||
switch (evt === null || evt === void 0 ? void 0 : evt.name) { | ||
// NotAllowedError means we tried playing the video before the user | ||
// interacted with the page (see https://goo.gl/xX8pDD) | ||
// Try calling play() in a few more seconds | ||
case "NotAllowedError": | ||
setTimeout(function () { | ||
return tryPlaying(playerRef); | ||
}, 3000); | ||
return; | ||
// The play request was aborted. For example: | ||
// "DOMException: The play() request was interrupted by a call to pause()" | ||
case "AbortError": | ||
return; | ||
// "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. | ||
case "NotSupportedError": | ||
if (!playerRef.current) { | ||
return; | ||
} | ||
break; | ||
} | ||
if (onError) { | ||
onError.apply(void 0, [evt, data].concat(_toConsumableArray(args))); | ||
} | ||
switch (classifyHlsError(evt, data)) { | ||
case HlsErrorType.NON_RECOVERABLE: | ||
UNPLAYABLE_HLS_URLS[selectedUrl] = true; | ||
playerRef.current = null; | ||
setRetryAttempt(function (x) { | ||
return x + 1; | ||
}); | ||
return; | ||
case HlsErrorType.AUTO_RECOVERABLE: | ||
// Ignore auto recoverable errors. They will be handled by hls.js | ||
return; | ||
case HlsErrorType.OTHER: | ||
default: | ||
if (autoRetry && !evt.defaultPrevented) { | ||
setTimeout(function () { | ||
playerRef.current = null; | ||
setRetryAttempt(function (x) { | ||
return x + 1; | ||
}); | ||
if (onRetryAttempt) { | ||
onRetryAttempt(); | ||
} | ||
}, 1000); | ||
} | ||
} | ||
} | ||
function tryPlaying(playerRef) { | ||
@@ -360,3 +372,3 @@ var _playerRef$current7, _playerRef$current7$g; | ||
export { VideoPlayer as default, ensureUrlObject }; | ||
export { VideoPlayer as default, ensureUrlObject, handlePlayerError }; | ||
//# sourceMappingURL=VideoPlayer.js.map |
{ | ||
"name": "@faintlines/video-player", | ||
"version": "2.5.6", | ||
"version": "2.5.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "license": "UNLICENSED", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1472726
11844
0