@faintlines/video-player
Advanced tools
Comparing version 1.10.0 to 1.11.0
@@ -617,2 +617,5 @@ import classnames from 'classnames'; | ||
function getCurrentSubtitleText(subtitles, currentTime) { | ||
if (typeof currentTime !== "number") { | ||
return null; | ||
} | ||
var currentSubtitle = subtitles.find(function (_ref2) { | ||
@@ -653,2 +656,3 @@ var _ref3 = _slicedToArray(_ref2, 2), | ||
var SubtitlesPlayerInner = function SubtitlesPlayerInner(_ref2) { | ||
var _playerRef$current, _playerRef$current$ge; | ||
var className = _ref2.className, | ||
@@ -658,3 +662,3 @@ subtitlesUrl = _ref2.subtitlesUrl, | ||
var subtitles = useRemoteSubtitles(subtitlesUrl); | ||
var _useState = useState(0), | ||
var _useState = useState((playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 : (_playerRef$current$ge = _playerRef$current.getInternalPlayer()) === null || _playerRef$current$ge === void 0 ? void 0 : _playerRef$current$ge.currentTime) || null), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
@@ -665,4 +669,4 @@ currentTime = _useState2[0], | ||
var intervalId = setInterval(function () { | ||
var _playerRef$current; | ||
var player = playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 : _playerRef$current.getInternalPlayer(); | ||
var _playerRef$current2; | ||
var player = playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current2 = playerRef.current) === null || _playerRef$current2 === void 0 ? void 0 : _playerRef$current2.getInternalPlayer(); | ||
if (player) { | ||
@@ -701,11 +705,19 @@ setCurrentTime(player.currentTime); | ||
useEffect(function () { | ||
var isUnmounted = false; | ||
fetchWithRetry(subtitlesUrl).then(function (response) { | ||
return response.text(); | ||
}).then(function (responseText) { | ||
var parsedSubtitles = parseSubtitlesText(responseText); | ||
setSubtitles(parsedSubtitles); | ||
if (!isUnmounted) { | ||
var parsedSubtitles = parseSubtitlesText(responseText); | ||
setSubtitles(parsedSubtitles); | ||
} | ||
})["catch"](function () { | ||
// subtitles is an empty array [], the component will render null. | ||
setSubtitles([]); | ||
if (!isUnmounted) { | ||
// subtitles is an empty array [], the component will render null. | ||
setSubtitles([]); | ||
} | ||
}); | ||
return function () { | ||
isUnmounted = true; | ||
}; | ||
}, [subtitlesUrl]); | ||
@@ -712,0 +724,0 @@ return subtitles; |
{ | ||
"name": "@faintlines/video-player", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "", | ||
@@ -34,3 +34,3 @@ "license": "UNLICENSED", | ||
}, | ||
"gitHead": "9abad2c8db7f33ecf9840efb036dd24e6f204ee1" | ||
"gitHead": "b2048c69b00c47c0af9760acff72ae87029a2806" | ||
} |
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
101452
1075