@nikelroot/video-player 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +9 -4
- package/dist/index.js +9 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -930,9 +930,11 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
930
930
|
}, []);
|
|
931
931
|
const ensureNativeMediaAttached = (0, import_react3.useCallback)(() => {
|
|
932
932
|
const video = videoRef.current;
|
|
933
|
-
if (!video || sourceLoadMode.current !== "native" || isVideoSourceAttached(video)) return;
|
|
933
|
+
if (!video || sourceLoadMode.current !== "native" || isVideoSourceAttached(video)) return false;
|
|
934
934
|
video.src = videoSrc;
|
|
935
935
|
if (initialTime > 0) video.currentTime = initialTime;
|
|
936
|
+
video.load();
|
|
937
|
+
return true;
|
|
936
938
|
}, [initialTime, videoSrc]);
|
|
937
939
|
const setNextPlaying = (0, import_react3.useCallback)(
|
|
938
940
|
(value) => {
|
|
@@ -1034,8 +1036,11 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
1034
1036
|
if (!el) return;
|
|
1035
1037
|
pendingPlay.current = true;
|
|
1036
1038
|
pauseOtherVideos(el);
|
|
1037
|
-
ensureNativeMediaAttached();
|
|
1038
|
-
if (sourceLoadMode.current === "native" && !canAttemptPlayback(el))
|
|
1039
|
+
const attachedNativeMedia = ensureNativeMediaAttached();
|
|
1040
|
+
if (sourceLoadMode.current === "native" && !canAttemptPlayback(el)) {
|
|
1041
|
+
if (attachedNativeMedia) clearErrorState();
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1039
1044
|
try {
|
|
1040
1045
|
await el.play();
|
|
1041
1046
|
pendingPlay.current = false;
|
|
@@ -1441,7 +1446,6 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
1441
1446
|
}, [muted]);
|
|
1442
1447
|
(0, import_react3.useEffect)(() => {
|
|
1443
1448
|
if (playingProp === void 0) return;
|
|
1444
|
-
if (!canAttemptPlayback(videoRef.current)) return;
|
|
1445
1449
|
if (playingProp) void playAction();
|
|
1446
1450
|
else pauseAction();
|
|
1447
1451
|
}, [pauseAction, playAction, playingProp]);
|
|
@@ -1586,6 +1590,7 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
1586
1590
|
onPlay: () => setNextPlaying(true),
|
|
1587
1591
|
onPause: () => setNextPlaying(false),
|
|
1588
1592
|
onEnded: () => setNextPlaying(false),
|
|
1593
|
+
onLoadedMetadata: videoLoadedHandler,
|
|
1589
1594
|
onLoadedData: videoLoadedHandler,
|
|
1590
1595
|
onCanPlay: videoLoadedHandler,
|
|
1591
1596
|
onError: videoErrorHandler,
|
package/dist/index.js
CHANGED
|
@@ -901,9 +901,11 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
901
901
|
}, []);
|
|
902
902
|
const ensureNativeMediaAttached = useCallback(() => {
|
|
903
903
|
const video = videoRef.current;
|
|
904
|
-
if (!video || sourceLoadMode.current !== "native" || isVideoSourceAttached(video)) return;
|
|
904
|
+
if (!video || sourceLoadMode.current !== "native" || isVideoSourceAttached(video)) return false;
|
|
905
905
|
video.src = videoSrc;
|
|
906
906
|
if (initialTime > 0) video.currentTime = initialTime;
|
|
907
|
+
video.load();
|
|
908
|
+
return true;
|
|
907
909
|
}, [initialTime, videoSrc]);
|
|
908
910
|
const setNextPlaying = useCallback(
|
|
909
911
|
(value) => {
|
|
@@ -1005,8 +1007,11 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
1005
1007
|
if (!el) return;
|
|
1006
1008
|
pendingPlay.current = true;
|
|
1007
1009
|
pauseOtherVideos(el);
|
|
1008
|
-
ensureNativeMediaAttached();
|
|
1009
|
-
if (sourceLoadMode.current === "native" && !canAttemptPlayback(el))
|
|
1010
|
+
const attachedNativeMedia = ensureNativeMediaAttached();
|
|
1011
|
+
if (sourceLoadMode.current === "native" && !canAttemptPlayback(el)) {
|
|
1012
|
+
if (attachedNativeMedia) clearErrorState();
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1010
1015
|
try {
|
|
1011
1016
|
await el.play();
|
|
1012
1017
|
pendingPlay.current = false;
|
|
@@ -1412,7 +1417,6 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
1412
1417
|
}, [muted]);
|
|
1413
1418
|
useEffect(() => {
|
|
1414
1419
|
if (playingProp === void 0) return;
|
|
1415
|
-
if (!canAttemptPlayback(videoRef.current)) return;
|
|
1416
1420
|
if (playingProp) void playAction();
|
|
1417
1421
|
else pauseAction();
|
|
1418
1422
|
}, [pauseAction, playAction, playingProp]);
|
|
@@ -1557,6 +1561,7 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
1557
1561
|
onPlay: () => setNextPlaying(true),
|
|
1558
1562
|
onPause: () => setNextPlaying(false),
|
|
1559
1563
|
onEnded: () => setNextPlaying(false),
|
|
1564
|
+
onLoadedMetadata: videoLoadedHandler,
|
|
1560
1565
|
onLoadedData: videoLoadedHandler,
|
|
1561
1566
|
onCanPlay: videoLoadedHandler,
|
|
1562
1567
|
onError: videoErrorHandler,
|