@faintlines/video-player
Advanced tools
Comparing version 1.3.11 to 1.3.12
@@ -182,3 +182,3 @@ import React, { forwardRef, useState, useRef, useEffect, useCallback, useMemo, useContext } from 'react'; | ||
var _excluded = ["url", "hlsUrl", "dashUrl", "fileUrl", "className", "progressInterval", "playsInline", "autoPlay", "preload", "poster", "controlsList", "onPlay", "onPause", "onProgress", "onLoadedMetadata"], | ||
var _excluded = ["url", "hlsUrl", "dashUrl", "fileUrl", "className", "progressInterval", "playsInline", "startAt", "autoPlay", "preload", "poster", "controlsList", "loopRange", "onPlay", "onPause", "onProgress", "onLoadedMetadata"], | ||
_excluded2 = ["children"]; | ||
@@ -197,2 +197,3 @@ | ||
playsInline = _ref.playsInline, | ||
startAt = _ref.startAt, | ||
autoPlay = _ref.autoPlay, | ||
@@ -202,2 +203,3 @@ preload = _ref.preload, | ||
controlsList = _ref.controlsList, | ||
loopRange = _ref.loopRange, | ||
onPlay = _ref.onPlay, | ||
@@ -215,2 +217,3 @@ onPause = _ref.onPause, | ||
var playerRef = useRef(); | ||
var loopRangeRef = useRef(loopRange); | ||
var urlObj = typeof url === "string" ? { | ||
@@ -252,2 +255,5 @@ file: url | ||
}, [ref]); | ||
useEffect(function () { | ||
loopRangeRef.current = loopRange; | ||
}, [loopRange]); | ||
var progressHandler = useCallback(function (progress) { | ||
@@ -258,2 +264,8 @@ if (ref && ref.current) { | ||
if (loopRangeRef.current) { | ||
var _playerRef$current6; | ||
applyLoopRange(loopRangeRef.current, progress.playedSeconds, playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current6 = playerRef.current) === null || _playerRef$current6 === void 0 ? void 0 : _playerRef$current6.getInternalPlayer()); | ||
} | ||
if (onProgress) { | ||
@@ -265,6 +277,12 @@ onProgress(progress); | ||
var metadataLoadedHandler = useCallback(function (evt) { | ||
var _playerRef$current7; | ||
var player = playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current7 = playerRef.current) === null || _playerRef$current7 === void 0 ? void 0 : _playerRef$current7.getInternalPlayer(); | ||
if (ref && ref.current) { | ||
var _playerRef$current6, _playerRef$current6$g; | ||
ref.current.duration = player === null || player === void 0 ? void 0 : player.duration; | ||
} | ||
ref.current.duration = playerRef === null || playerRef === void 0 ? void 0 : (_playerRef$current6 = playerRef.current) === null || _playerRef$current6 === void 0 ? void 0 : (_playerRef$current6$g = _playerRef$current6.getInternalPlayer()) === null || _playerRef$current6$g === void 0 ? void 0 : _playerRef$current6$g.duration; | ||
if (startAt && player) { | ||
player.currentTime = startAt; | ||
} | ||
@@ -276,3 +294,3 @@ | ||
}, // eslint-disable-next-line react-hooks/exhaustive-deps | ||
[onLoadedMetadata]); | ||
[onLoadedMetadata, startAt]); | ||
var playHandler = useCallback(function (evt) { | ||
@@ -379,3 +397,15 @@ if (ref && ref.current) { | ||
function applyLoopRange(range, currentTime, player) { | ||
var _range = _slicedToArray(range, 3), | ||
start = _range[0], | ||
end = _range[1], | ||
jumpToStart = _range[2]; // not jumping to start | ||
if (currentTime >= end || jumpToStart && currentTime < start) { | ||
player.currentTime = start; | ||
} | ||
} | ||
export { VideoPlayer as default }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@faintlines/video-player", | ||
"version": "1.3.11", | ||
"version": "1.3.12", | ||
"description": "", | ||
@@ -44,3 +44,3 @@ "license": "UNLICENSED", | ||
}, | ||
"gitHead": "f6aed36be789e063e5275ae20ad1c2708430759b" | ||
"gitHead": "014ccdb18e173cfde6e2a36dca7efd41b0a7d2b0" | ||
} |
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
31130
335