remotion 4.0.14 → 4.0.16
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/cjs/use-media-playback.js +25 -10
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/index.mjs +26 -11
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
|
@@ -32,8 +32,18 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
|
|
|
32
32
|
if (!src) {
|
|
33
33
|
throw new Error(`No 'src' attribute was passed to the ${tagName} element.`);
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const playbackRateToSet = Math.max(0, playbackRate);
|
|
36
|
+
if (mediaRef.current.playbackRate !== playbackRateToSet) {
|
|
37
|
+
mediaRef.current.playbackRate = playbackRateToSet;
|
|
38
|
+
}
|
|
39
|
+
// Let's throttle the seeking to only every 10 frames when a video is playing to avoid bottlenecking
|
|
40
|
+
// the video tag.
|
|
41
|
+
if (playing) {
|
|
42
|
+
if (absoluteFrame % 10 !== 0) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const desiredUnclampedTime = (0, get_current_time_js_1.getMediaTime)({
|
|
37
47
|
fps,
|
|
38
48
|
frame,
|
|
39
49
|
src,
|
|
@@ -41,15 +51,20 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
|
|
|
41
51
|
startFrom: -mediaStartsAt,
|
|
42
52
|
mediaType,
|
|
43
53
|
});
|
|
54
|
+
const { duration } = mediaRef.current;
|
|
55
|
+
const shouldBeTime = !Number.isNaN(duration) && Number.isFinite(duration)
|
|
56
|
+
? Math.min(duration, desiredUnclampedTime)
|
|
57
|
+
: desiredUnclampedTime;
|
|
44
58
|
const isTime = mediaRef.current.currentTime;
|
|
45
59
|
const timeShift = Math.abs(shouldBeTime - isTime);
|
|
46
|
-
if (timeShift > acceptableTimeshift
|
|
60
|
+
if (timeShift > acceptableTimeshift) {
|
|
47
61
|
// If scrubbing around, adjust timing
|
|
48
|
-
// or if time shift is bigger than 0.
|
|
62
|
+
// or if time shift is bigger than 0.45sec
|
|
49
63
|
mediaRef.current.currentTime = shouldBeTime;
|
|
50
64
|
if (!onlyWarnForMediaSeekingError) {
|
|
51
65
|
(0, warn_about_non_seekable_media_js_1.warnAboutNonSeekableMedia)(mediaRef.current, onlyWarnForMediaSeekingError ? 'console-warning' : 'console-error');
|
|
52
66
|
}
|
|
67
|
+
return;
|
|
53
68
|
}
|
|
54
69
|
// Only perform a seek if the time is not already the same.
|
|
55
70
|
// Chrome rounds to 6 digits, so 0.033333333 -> 0.033333,
|
|
@@ -57,15 +72,15 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
|
|
|
57
72
|
// Refer to the https://github.com/remotion-dev/video-buffering-example
|
|
58
73
|
// which is fixed by only seeking conditionally.
|
|
59
74
|
const makesSenseToSeek = Math.abs(mediaRef.current.currentTime - shouldBeTime) > 0.00001;
|
|
75
|
+
if (!makesSenseToSeek) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
60
78
|
if (!playing || absoluteFrame === 0) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
79
|
+
mediaRef.current.currentTime = shouldBeTime;
|
|
80
|
+
return;
|
|
64
81
|
}
|
|
65
82
|
if (mediaRef.current.paused && !mediaRef.current.ended && playing) {
|
|
66
|
-
|
|
67
|
-
mediaRef.current.currentTime = shouldBeTime;
|
|
68
|
-
}
|
|
83
|
+
mediaRef.current.currentTime = shouldBeTime;
|
|
69
84
|
(0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)(mediaRef, mediaType);
|
|
70
85
|
}
|
|
71
86
|
}, [
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.0.
|
|
1
|
+
export declare const VERSION = "4.0.16";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/index.mjs
CHANGED
|
@@ -59,7 +59,7 @@ function truthy(value) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// Automatically generated on publish
|
|
62
|
-
const VERSION = '4.0.
|
|
62
|
+
const VERSION = '4.0.16';
|
|
63
63
|
|
|
64
64
|
const checkMultipleRemotionVersions = () => {
|
|
65
65
|
if (typeof globalThis === 'undefined') {
|
|
@@ -1772,8 +1772,18 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
|
|
|
1772
1772
|
if (!src) {
|
|
1773
1773
|
throw new Error(`No 'src' attribute was passed to the ${tagName} element.`);
|
|
1774
1774
|
}
|
|
1775
|
-
|
|
1776
|
-
|
|
1775
|
+
const playbackRateToSet = Math.max(0, playbackRate);
|
|
1776
|
+
if (mediaRef.current.playbackRate !== playbackRateToSet) {
|
|
1777
|
+
mediaRef.current.playbackRate = playbackRateToSet;
|
|
1778
|
+
}
|
|
1779
|
+
// Let's throttle the seeking to only every 10 frames when a video is playing to avoid bottlenecking
|
|
1780
|
+
// the video tag.
|
|
1781
|
+
if (playing) {
|
|
1782
|
+
if (absoluteFrame % 10 !== 0) {
|
|
1783
|
+
return;
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
const desiredUnclampedTime = getMediaTime({
|
|
1777
1787
|
fps,
|
|
1778
1788
|
frame,
|
|
1779
1789
|
src,
|
|
@@ -1781,15 +1791,20 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
|
|
|
1781
1791
|
startFrom: -mediaStartsAt,
|
|
1782
1792
|
mediaType,
|
|
1783
1793
|
});
|
|
1794
|
+
const { duration } = mediaRef.current;
|
|
1795
|
+
const shouldBeTime = !Number.isNaN(duration) && Number.isFinite(duration)
|
|
1796
|
+
? Math.min(duration, desiredUnclampedTime)
|
|
1797
|
+
: desiredUnclampedTime;
|
|
1784
1798
|
const isTime = mediaRef.current.currentTime;
|
|
1785
1799
|
const timeShift = Math.abs(shouldBeTime - isTime);
|
|
1786
|
-
if (timeShift > acceptableTimeshift
|
|
1800
|
+
if (timeShift > acceptableTimeshift) {
|
|
1787
1801
|
// If scrubbing around, adjust timing
|
|
1788
|
-
// or if time shift is bigger than 0.
|
|
1802
|
+
// or if time shift is bigger than 0.45sec
|
|
1789
1803
|
mediaRef.current.currentTime = shouldBeTime;
|
|
1790
1804
|
if (!onlyWarnForMediaSeekingError) {
|
|
1791
1805
|
warnAboutNonSeekableMedia(mediaRef.current, onlyWarnForMediaSeekingError ? 'console-warning' : 'console-error');
|
|
1792
1806
|
}
|
|
1807
|
+
return;
|
|
1793
1808
|
}
|
|
1794
1809
|
// Only perform a seek if the time is not already the same.
|
|
1795
1810
|
// Chrome rounds to 6 digits, so 0.033333333 -> 0.033333,
|
|
@@ -1797,15 +1812,15 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
|
|
|
1797
1812
|
// Refer to the https://github.com/remotion-dev/video-buffering-example
|
|
1798
1813
|
// which is fixed by only seeking conditionally.
|
|
1799
1814
|
const makesSenseToSeek = Math.abs(mediaRef.current.currentTime - shouldBeTime) > 0.00001;
|
|
1815
|
+
if (!makesSenseToSeek) {
|
|
1816
|
+
return;
|
|
1817
|
+
}
|
|
1800
1818
|
if (!playing || absoluteFrame === 0) {
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
}
|
|
1819
|
+
mediaRef.current.currentTime = shouldBeTime;
|
|
1820
|
+
return;
|
|
1804
1821
|
}
|
|
1805
1822
|
if (mediaRef.current.paused && !mediaRef.current.ended && playing) {
|
|
1806
|
-
|
|
1807
|
-
mediaRef.current.currentTime = shouldBeTime;
|
|
1808
|
-
}
|
|
1823
|
+
mediaRef.current.currentTime = shouldBeTime;
|
|
1809
1824
|
playAndHandleNotAllowedError(mediaRef, mediaType);
|
|
1810
1825
|
}
|
|
1811
1826
|
}, [
|
package/dist/esm/version.mjs
CHANGED