@remotion/player 4.0.540 → 4.0.541
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/index.d.ts +30 -0
- package/dist/cjs/index.js +2 -0
- package/dist/esm/index.mjs +1750 -1749
- package/package.json +3 -3
package/dist/esm/index.mjs
CHANGED
|
@@ -505,14 +505,139 @@ var PlayerEmitterProvider = ({ children, currentPlaybackRate }) => {
|
|
|
505
505
|
});
|
|
506
506
|
};
|
|
507
507
|
|
|
508
|
-
// src/
|
|
509
|
-
import
|
|
510
|
-
|
|
508
|
+
// src/PlayerControls.tsx
|
|
509
|
+
import { useCallback as useCallback7, useEffect as useEffect7, useMemo as useMemo9, useRef as useRef5, useState as useState9 } from "react";
|
|
510
|
+
|
|
511
|
+
// src/DefaultPlayPauseButton.tsx
|
|
512
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
513
|
+
var DefaultPlayPauseButton = ({ playing, buffering }) => {
|
|
514
|
+
if (playing && buffering) {
|
|
515
|
+
return /* @__PURE__ */ jsx4(BufferingIndicator, {
|
|
516
|
+
type: "player"
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
if (playing) {
|
|
520
|
+
return /* @__PURE__ */ jsx4(PauseIcon, {});
|
|
521
|
+
}
|
|
522
|
+
return /* @__PURE__ */ jsx4(PlayIcon, {});
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
// src/MediaVolumeSlider.tsx
|
|
526
|
+
import { useCallback as useCallback2, useMemo as useMemo2, useRef, useState as useState4 } from "react";
|
|
527
|
+
import { Internals as Internals3 } from "remotion";
|
|
528
|
+
|
|
529
|
+
// src/render-volume-slider.tsx
|
|
530
|
+
import React3, { useCallback, useMemo, useState as useState2 } from "react";
|
|
531
|
+
import { random } from "remotion";
|
|
532
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
533
|
+
var KNOB_SIZE = 12;
|
|
534
|
+
var BAR_HEIGHT = 5;
|
|
535
|
+
var DefaultVolumeSlider = ({
|
|
536
|
+
volume,
|
|
537
|
+
isVertical,
|
|
538
|
+
onBlur,
|
|
539
|
+
inputRef,
|
|
540
|
+
setVolume
|
|
541
|
+
}) => {
|
|
542
|
+
const sliderContainer = useMemo(() => {
|
|
543
|
+
const paddingLeft = 5;
|
|
544
|
+
const common = {
|
|
545
|
+
paddingLeft,
|
|
546
|
+
height: ICON_SIZE,
|
|
547
|
+
width: VOLUME_SLIDER_WIDTH,
|
|
548
|
+
display: "inline-flex",
|
|
549
|
+
alignItems: "center"
|
|
550
|
+
};
|
|
551
|
+
if (isVertical) {
|
|
552
|
+
return {
|
|
553
|
+
...common,
|
|
554
|
+
position: "absolute",
|
|
555
|
+
transform: `rotate(-90deg) translateX(${VOLUME_SLIDER_WIDTH / 2 + ICON_SIZE / 2}px)`
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
return {
|
|
559
|
+
...common
|
|
560
|
+
};
|
|
561
|
+
}, [isVertical]);
|
|
562
|
+
const randomId = typeof React3.useId === "undefined" ? "volume-slider" : React3.useId();
|
|
563
|
+
const [randomClass] = useState2(() => `__remotion-volume-slider-${random(randomId)}`.replace(".", ""));
|
|
564
|
+
const onVolumeChange = useCallback((e) => {
|
|
565
|
+
setVolume(parseFloat(e.target.value));
|
|
566
|
+
}, [setVolume]);
|
|
567
|
+
const inputStyle = useMemo(() => {
|
|
568
|
+
const commonStyle = {
|
|
569
|
+
WebkitAppearance: "none",
|
|
570
|
+
backgroundColor: "rgba(255, 255, 255, 0.5)",
|
|
571
|
+
borderRadius: BAR_HEIGHT / 2,
|
|
572
|
+
cursor: "pointer",
|
|
573
|
+
height: BAR_HEIGHT,
|
|
574
|
+
width: VOLUME_SLIDER_WIDTH,
|
|
575
|
+
backgroundImage: `linear-gradient(
|
|
576
|
+
to right,
|
|
577
|
+
white ${volume * 100}%, rgba(255, 255, 255, 0) ${volume * 100}%
|
|
578
|
+
)`
|
|
579
|
+
};
|
|
580
|
+
if (isVertical) {
|
|
581
|
+
return {
|
|
582
|
+
...commonStyle,
|
|
583
|
+
bottom: ICON_SIZE + VOLUME_SLIDER_WIDTH / 2
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
return commonStyle;
|
|
587
|
+
}, [isVertical, volume]);
|
|
588
|
+
const sliderStyle = `
|
|
589
|
+
.${randomClass}::-webkit-slider-thumb {
|
|
590
|
+
-webkit-appearance: none;
|
|
591
|
+
background-color: white;
|
|
592
|
+
border-radius: ${KNOB_SIZE / 2}px;
|
|
593
|
+
box-shadow: 0 0 2px black;
|
|
594
|
+
height: ${KNOB_SIZE}px;
|
|
595
|
+
width: ${KNOB_SIZE}px;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.${randomClass}::-moz-range-thumb {
|
|
599
|
+
-webkit-appearance: none;
|
|
600
|
+
background-color: white;
|
|
601
|
+
border-radius: ${KNOB_SIZE / 2}px;
|
|
602
|
+
box-shadow: 0 0 2px black;
|
|
603
|
+
height: ${KNOB_SIZE}px;
|
|
604
|
+
width: ${KNOB_SIZE}px;
|
|
605
|
+
}
|
|
606
|
+
`;
|
|
607
|
+
return /* @__PURE__ */ jsxs3("div", {
|
|
608
|
+
style: sliderContainer,
|
|
609
|
+
children: [
|
|
610
|
+
/* @__PURE__ */ jsx5("style", {
|
|
611
|
+
dangerouslySetInnerHTML: {
|
|
612
|
+
__html: sliderStyle
|
|
613
|
+
}
|
|
614
|
+
}),
|
|
615
|
+
/* @__PURE__ */ jsx5("input", {
|
|
616
|
+
ref: inputRef,
|
|
617
|
+
"aria-label": "Change volume",
|
|
618
|
+
className: randomClass,
|
|
619
|
+
max: 1,
|
|
620
|
+
min: 0,
|
|
621
|
+
onBlur,
|
|
622
|
+
onChange: onVolumeChange,
|
|
623
|
+
step: 0.01,
|
|
624
|
+
type: "range",
|
|
625
|
+
value: volume,
|
|
626
|
+
style: inputStyle
|
|
627
|
+
})
|
|
628
|
+
]
|
|
629
|
+
});
|
|
630
|
+
};
|
|
631
|
+
var renderDefaultVolumeSlider = (props) => {
|
|
632
|
+
return /* @__PURE__ */ jsx5(DefaultVolumeSlider, {
|
|
633
|
+
...props
|
|
634
|
+
});
|
|
635
|
+
};
|
|
511
636
|
|
|
512
637
|
// src/use-hover-state.ts
|
|
513
|
-
import { useEffect as useEffect2, useState as
|
|
638
|
+
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
514
639
|
var useHoverState = (ref, hideControlsWhenPointerDoesntMove) => {
|
|
515
|
-
const [hovered, setHovered] =
|
|
640
|
+
const [hovered, setHovered] = useState3(false);
|
|
516
641
|
useEffect2(() => {
|
|
517
642
|
const { current } = ref;
|
|
518
643
|
if (!current) {
|
|
@@ -552,747 +677,574 @@ var useHoverState = (ref, hideControlsWhenPointerDoesntMove) => {
|
|
|
552
677
|
return hovered;
|
|
553
678
|
};
|
|
554
679
|
|
|
555
|
-
// src/
|
|
556
|
-
import {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
const {
|
|
570
|
-
setPlaying,
|
|
571
|
-
frameRef,
|
|
572
|
-
audioAndVideoTags,
|
|
573
|
-
isPlaying: readIsPlaying,
|
|
574
|
-
isBuffering
|
|
575
|
-
} = useContext2(Internals3.SetTimelineContext);
|
|
576
|
-
const audioContext = useContext2(Internals3.SharedAudioContext);
|
|
577
|
-
const audioTagsContext = useContext2(Internals3.SharedAudioTagsContext);
|
|
578
|
-
const { playerMuted, mediaVolume } = useContext2(Internals3.MediaVolumeContext);
|
|
579
|
-
const muted = playerMuted || mediaVolume === 0;
|
|
580
|
-
const environment = useRemotionEnvironment();
|
|
581
|
-
const video = Internals3.useVideo();
|
|
582
|
-
const videoId = video?.id ?? null;
|
|
583
|
-
const videoDurationInFrames = video?.durationInFrames ?? null;
|
|
584
|
-
const config = Internals3.useUnsafeVideoConfig();
|
|
585
|
-
const emitter = useContext2(PlayerEventEmitterContext);
|
|
586
|
-
const playStart = useRef(0);
|
|
587
|
-
const fallbackFrame = useRef(null);
|
|
588
|
-
const nextPlayIsAutoPlayAttempt = useRef(false);
|
|
589
|
-
if (!emitter) {
|
|
590
|
-
throw new TypeError("Expected Player event emitter context");
|
|
591
|
-
}
|
|
592
|
-
const getCurrentFrame = useCallback(() => {
|
|
593
|
-
if (videoId === null || videoDurationInFrames === null) {
|
|
594
|
-
return fallbackFrame.current ?? (typeof window === "undefined" ? 0 : window.remotion_initialFrame ?? 0);
|
|
595
|
-
}
|
|
596
|
-
const unclamped = frameRef.current[videoId] ?? (environment.isPlayer ? 0 : Internals3.Timeline.getFrameForComposition(videoId));
|
|
597
|
-
return Internals3.Timeline.clampFrameToCompositionRange(unclamped, videoDurationInFrames);
|
|
598
|
-
}, [environment.isPlayer, frameRef, videoId, videoDurationInFrames]);
|
|
599
|
-
const seek = useCallback((newFrame) => {
|
|
600
|
-
const frameToSeekTo = config ? Internals3.TimelinePosition.clampFrameToCompositionRange(newFrame, config.durationInFrames) : Math.max(0, newFrame);
|
|
601
|
-
fallbackFrame.current = frameToSeekTo;
|
|
602
|
-
if (video?.id) {
|
|
603
|
-
seekFrame((currentFrames) => currentFrames[video.id] === frameToSeekTo ? currentFrames : { ...currentFrames, [video.id]: frameToSeekTo });
|
|
604
|
-
if (frameRef.current[video.id] !== frameToSeekTo) {
|
|
605
|
-
frameRef.current = {
|
|
606
|
-
...frameRef.current,
|
|
607
|
-
[video.id]: frameToSeekTo
|
|
608
|
-
};
|
|
680
|
+
// src/MediaVolumeSlider.tsx
|
|
681
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
682
|
+
var VOLUME_SLIDER_WIDTH = 100;
|
|
683
|
+
var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, renderVolumeSlider }) => {
|
|
684
|
+
const [playerMuted, setPlayerMuted] = Internals3.usePlayerMutedState();
|
|
685
|
+
const [mediaVolume, setMediaVolume] = Internals3.useMediaVolumeState();
|
|
686
|
+
const [focused, setFocused] = useState4(false);
|
|
687
|
+
const parentDivRef = useRef(null);
|
|
688
|
+
const inputRef = useRef(null);
|
|
689
|
+
const hover = useHoverState(parentDivRef, false);
|
|
690
|
+
const onBlur = useCallback2(() => {
|
|
691
|
+
setTimeout(() => {
|
|
692
|
+
if (inputRef.current && document.activeElement !== inputRef.current) {
|
|
693
|
+
setFocused(false);
|
|
609
694
|
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
695
|
+
}, 10);
|
|
696
|
+
}, []);
|
|
697
|
+
const isVolume0 = mediaVolume === 0;
|
|
698
|
+
const onClick = useCallback2(() => {
|
|
699
|
+
if (isVolume0) {
|
|
700
|
+
setMediaVolume(1);
|
|
701
|
+
setPlayerMuted(false);
|
|
617
702
|
return;
|
|
618
703
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
704
|
+
setPlayerMuted((mute) => !mute);
|
|
705
|
+
}, [isVolume0, setPlayerMuted, setMediaVolume]);
|
|
706
|
+
const parentDivStyle = useMemo2(() => {
|
|
707
|
+
return {
|
|
708
|
+
display: "inline-flex",
|
|
709
|
+
background: "none",
|
|
710
|
+
border: "none",
|
|
711
|
+
justifyContent: "center",
|
|
712
|
+
alignItems: "center",
|
|
713
|
+
touchAction: "none",
|
|
714
|
+
...displayVerticalVolumeSlider && { position: "relative" }
|
|
715
|
+
};
|
|
716
|
+
}, [displayVerticalVolumeSlider]);
|
|
717
|
+
const volumeContainer = useMemo2(() => {
|
|
718
|
+
return {
|
|
719
|
+
display: "inline",
|
|
720
|
+
width: ICON_SIZE,
|
|
721
|
+
height: ICON_SIZE,
|
|
722
|
+
cursor: "pointer",
|
|
723
|
+
appearance: "none",
|
|
724
|
+
background: "none",
|
|
725
|
+
border: "none",
|
|
726
|
+
padding: 0
|
|
727
|
+
};
|
|
728
|
+
}, []);
|
|
729
|
+
const renderDefaultMuteButton = useCallback2(({ muted, volume }) => {
|
|
730
|
+
const isMutedOrZero = muted || volume === 0;
|
|
731
|
+
return /* @__PURE__ */ jsx6("button", {
|
|
732
|
+
"aria-label": isMutedOrZero ? "Unmute sound" : "Mute sound",
|
|
733
|
+
title: isMutedOrZero ? "Unmute sound" : "Mute sound",
|
|
734
|
+
onClick,
|
|
735
|
+
onBlur,
|
|
736
|
+
onFocus: () => setFocused(true),
|
|
737
|
+
style: volumeContainer,
|
|
738
|
+
type: "button",
|
|
739
|
+
children: isMutedOrZero ? /* @__PURE__ */ jsx6(VolumeOffIcon, {}) : /* @__PURE__ */ jsx6(VolumeOnIcon, {})
|
|
740
|
+
});
|
|
741
|
+
}, [onBlur, onClick, volumeContainer]);
|
|
742
|
+
const muteButton = useMemo2(() => {
|
|
743
|
+
return renderMuteButton ? renderMuteButton({ muted: playerMuted, volume: mediaVolume }) : renderDefaultMuteButton({ muted: playerMuted, volume: mediaVolume });
|
|
744
|
+
}, [playerMuted, mediaVolume, renderDefaultMuteButton, renderMuteButton]);
|
|
745
|
+
const volumeSlider = useMemo2(() => {
|
|
746
|
+
return (focused || hover) && !playerMuted && !Internals3.isIosSafari() ? (renderVolumeSlider ?? renderDefaultVolumeSlider)({
|
|
747
|
+
isVertical: displayVerticalVolumeSlider,
|
|
748
|
+
volume: mediaVolume,
|
|
749
|
+
onBlur: () => setFocused(false),
|
|
750
|
+
inputRef,
|
|
751
|
+
setVolume: setMediaVolume
|
|
752
|
+
}) : null;
|
|
637
753
|
}, [
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
readIsPlaying,
|
|
646
|
-
seek,
|
|
647
|
-
setPlaying
|
|
754
|
+
displayVerticalVolumeSlider,
|
|
755
|
+
focused,
|
|
756
|
+
hover,
|
|
757
|
+
playerMuted,
|
|
758
|
+
mediaVolume,
|
|
759
|
+
renderVolumeSlider,
|
|
760
|
+
setMediaVolume
|
|
648
761
|
]);
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
};
|
|
673
|
-
emitter.dispatchPause();
|
|
762
|
+
return /* @__PURE__ */ jsxs4("div", {
|
|
763
|
+
ref: parentDivRef,
|
|
764
|
+
style: parentDivStyle,
|
|
765
|
+
children: [
|
|
766
|
+
muteButton,
|
|
767
|
+
volumeSlider
|
|
768
|
+
]
|
|
769
|
+
});
|
|
770
|
+
};
|
|
771
|
+
|
|
772
|
+
// src/PlaybackrateControl.tsx
|
|
773
|
+
import { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo3, useState as useState6 } from "react";
|
|
774
|
+
import { Internals as Internals4 } from "remotion";
|
|
775
|
+
|
|
776
|
+
// src/utils/use-component-visible.ts
|
|
777
|
+
import { useEffect as useEffect3, useRef as useRef2, useState as useState5 } from "react";
|
|
778
|
+
function useComponentVisible(initialIsVisible) {
|
|
779
|
+
const [isComponentVisible, setIsComponentVisible] = useState5(initialIsVisible);
|
|
780
|
+
const ref = useRef2(null);
|
|
781
|
+
useEffect3(() => {
|
|
782
|
+
const handleClickOutside = (event) => {
|
|
783
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
784
|
+
setIsComponentVisible(false);
|
|
674
785
|
}
|
|
675
|
-
}
|
|
676
|
-
}, [config, emitter, frameRef, readIsPlaying, setPlaying, seekFrame]);
|
|
677
|
-
const lastFrame = (config?.durationInFrames ?? 1) - 1;
|
|
678
|
-
const frameBack = useCallback((frames) => {
|
|
679
|
-
if (!videoId) {
|
|
680
|
-
return null;
|
|
681
|
-
}
|
|
682
|
-
if (readIsPlaying()) {
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
const previousFrame = frameRef.current[videoId] ?? window.remotion_initialFrame ?? 0;
|
|
686
|
-
const newFrame = Math.max(0, previousFrame - frames);
|
|
687
|
-
if (previousFrame === newFrame) {
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
seekFrame((currentFrames) => currentFrames[videoId] === newFrame ? currentFrames : { ...currentFrames, [videoId]: newFrame });
|
|
691
|
-
frameRef.current = {
|
|
692
|
-
...frameRef.current,
|
|
693
|
-
[videoId]: newFrame
|
|
694
786
|
};
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
return null;
|
|
699
|
-
}
|
|
700
|
-
if (readIsPlaying()) {
|
|
701
|
-
return;
|
|
702
|
-
}
|
|
703
|
-
const previousFrame = frameRef.current[videoId] ?? window.remotion_initialFrame ?? 0;
|
|
704
|
-
const newFrame = Math.min(lastFrame, previousFrame + frames);
|
|
705
|
-
if (previousFrame === newFrame) {
|
|
706
|
-
return;
|
|
707
|
-
}
|
|
708
|
-
seekFrame((currentFrames) => currentFrames[videoId] === newFrame ? currentFrames : { ...currentFrames, [videoId]: newFrame });
|
|
709
|
-
frameRef.current = {
|
|
710
|
-
...frameRef.current,
|
|
711
|
-
[videoId]: newFrame
|
|
787
|
+
document.addEventListener("pointerup", handleClickOutside, true);
|
|
788
|
+
return () => {
|
|
789
|
+
document.removeEventListener("pointerup", handleClickOutside, true);
|
|
712
790
|
};
|
|
713
|
-
}, [
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
791
|
+
}, []);
|
|
792
|
+
return { ref, isComponentVisible, setIsComponentVisible };
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// src/PlaybackrateControl.tsx
|
|
796
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
797
|
+
var BOTTOM = 35;
|
|
798
|
+
var THRESHOLD = 70;
|
|
799
|
+
var rateDiv = {
|
|
800
|
+
height: 30,
|
|
801
|
+
paddingRight: 15,
|
|
802
|
+
paddingLeft: 12,
|
|
803
|
+
display: "flex",
|
|
804
|
+
flexDirection: "row",
|
|
805
|
+
alignItems: "center"
|
|
806
|
+
};
|
|
807
|
+
var checkmarkContainer = {
|
|
808
|
+
width: 22,
|
|
809
|
+
display: "flex",
|
|
810
|
+
alignItems: "center"
|
|
811
|
+
};
|
|
812
|
+
var checkmarkStyle = {
|
|
813
|
+
width: 14,
|
|
814
|
+
height: 14,
|
|
815
|
+
color: "black"
|
|
816
|
+
};
|
|
817
|
+
var Checkmark = () => /* @__PURE__ */ jsx7("svg", {
|
|
818
|
+
viewBox: "0 0 512 512",
|
|
819
|
+
style: checkmarkStyle,
|
|
820
|
+
children: /* @__PURE__ */ jsx7("path", {
|
|
821
|
+
fill: "currentColor",
|
|
822
|
+
d: "M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"
|
|
823
|
+
})
|
|
824
|
+
});
|
|
825
|
+
var formatPlaybackRate = (rate) => {
|
|
826
|
+
const str = rate.toString();
|
|
827
|
+
return str.includes(".") ? str : str + ".0";
|
|
828
|
+
};
|
|
829
|
+
var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }) => {
|
|
830
|
+
const onClick = useCallback3((e) => {
|
|
831
|
+
e.stopPropagation();
|
|
832
|
+
e.preventDefault();
|
|
833
|
+
onSelect(rate);
|
|
834
|
+
}, [onSelect, rate]);
|
|
835
|
+
const [hovered, setHovered] = useState6(false);
|
|
836
|
+
const onMouseEnter = useCallback3(() => {
|
|
837
|
+
setHovered(true);
|
|
838
|
+
}, []);
|
|
839
|
+
const onMouseLeave = useCallback3(() => {
|
|
840
|
+
setHovered(false);
|
|
841
|
+
}, []);
|
|
842
|
+
const isFocused = keyboardSelectedRate === rate;
|
|
843
|
+
const actualStyle = useMemo3(() => {
|
|
722
844
|
return {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
emitter,
|
|
726
|
-
play,
|
|
727
|
-
playAsAutoPlay,
|
|
728
|
-
pause,
|
|
729
|
-
seek,
|
|
730
|
-
getCurrentFrame,
|
|
731
|
-
isPlaying: readIsPlaying,
|
|
732
|
-
isBuffering,
|
|
733
|
-
pauseAndReturnToPlayStart,
|
|
734
|
-
toggle
|
|
845
|
+
...rateDiv,
|
|
846
|
+
backgroundColor: hovered || isFocused ? "#eee" : "transparent"
|
|
735
847
|
};
|
|
736
|
-
}, [
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
848
|
+
}, [hovered, isFocused]);
|
|
849
|
+
return /* @__PURE__ */ jsxs5("div", {
|
|
850
|
+
onPointerEnter: onMouseEnter,
|
|
851
|
+
onPointerLeave: onMouseLeave,
|
|
852
|
+
tabIndex: 0,
|
|
853
|
+
style: actualStyle,
|
|
854
|
+
onClick,
|
|
855
|
+
children: [
|
|
856
|
+
/* @__PURE__ */ jsx7("div", {
|
|
857
|
+
style: checkmarkContainer,
|
|
858
|
+
children: rate === selectedRate ? /* @__PURE__ */ jsx7(Checkmark, {}) : null
|
|
859
|
+
}),
|
|
860
|
+
formatPlaybackRate(rate),
|
|
861
|
+
"x"
|
|
862
|
+
]
|
|
863
|
+
}, rate);
|
|
750
864
|
};
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
}) => {
|
|
758
|
-
const playing = Internals4.usePlaying();
|
|
759
|
-
const { pause, play, emitter, getCurrentFrame, seek } = usePlayerMethods();
|
|
760
|
-
const hasEverPlayed = useRef2(false);
|
|
761
|
-
useEffect3(() => {
|
|
762
|
-
if (playing) {
|
|
763
|
-
hasEverPlayed.current = true;
|
|
764
|
-
}
|
|
765
|
-
if (!navigator.mediaSession) {
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
if (browserMediaControlsBehavior.mode === "do-nothing") {
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
if (playing) {
|
|
772
|
-
navigator.mediaSession.playbackState = "playing";
|
|
773
|
-
} else if (hasEverPlayed.current) {
|
|
774
|
-
navigator.mediaSession.playbackState = "paused";
|
|
775
|
-
}
|
|
776
|
-
}, [browserMediaControlsBehavior.mode, playing]);
|
|
777
|
-
useEffect3(() => {
|
|
778
|
-
if (!navigator.mediaSession) {
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
if (browserMediaControlsBehavior.mode === "do-nothing") {
|
|
782
|
-
return;
|
|
783
|
-
}
|
|
784
|
-
const onTimeUpdate = () => {
|
|
785
|
-
if (!videoConfig) {
|
|
865
|
+
var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
|
|
866
|
+
const { setPlaybackRate, playbackRate } = Internals4.usePlaybackRate();
|
|
867
|
+
const [keyboardSelectedRate, setKeyboardSelectedRate] = useState6(playbackRate);
|
|
868
|
+
useEffect4(() => {
|
|
869
|
+
const listener = (e) => {
|
|
870
|
+
if (e.ctrlKey || e.metaKey || e.altKey) {
|
|
786
871
|
return;
|
|
787
872
|
}
|
|
788
|
-
if (
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
}
|
|
873
|
+
if (e.key === "ArrowUp") {
|
|
874
|
+
e.preventDefault();
|
|
875
|
+
const currentIndex = playbackRates.findIndex((rate) => rate === keyboardSelectedRate);
|
|
876
|
+
if (currentIndex === 0) {
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
if (currentIndex === -1) {
|
|
880
|
+
setKeyboardSelectedRate(playbackRates[0]);
|
|
881
|
+
} else {
|
|
882
|
+
setKeyboardSelectedRate(playbackRates[currentIndex - 1]);
|
|
883
|
+
}
|
|
884
|
+
} else if (e.key === "ArrowDown") {
|
|
885
|
+
e.preventDefault();
|
|
886
|
+
const currentIndex = playbackRates.findIndex((rate) => rate === keyboardSelectedRate);
|
|
887
|
+
if (currentIndex === playbackRates.length - 1) {
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
if (currentIndex === -1) {
|
|
891
|
+
setKeyboardSelectedRate(playbackRates[playbackRates.length - 1]);
|
|
892
|
+
} else {
|
|
893
|
+
setKeyboardSelectedRate(playbackRates[currentIndex + 1]);
|
|
894
|
+
}
|
|
895
|
+
} else if (e.key === "Enter") {
|
|
896
|
+
e.preventDefault();
|
|
897
|
+
setPlaybackRate(keyboardSelectedRate);
|
|
898
|
+
setIsComponentVisible(false);
|
|
899
|
+
} else if (e.key === "Escape") {
|
|
900
|
+
e.preventDefault();
|
|
901
|
+
setIsComponentVisible(false);
|
|
902
|
+
} else if (e.key === "Tab") {
|
|
903
|
+
setIsComponentVisible(false);
|
|
794
904
|
}
|
|
795
905
|
};
|
|
796
|
-
|
|
906
|
+
window.addEventListener("keydown", listener);
|
|
797
907
|
return () => {
|
|
798
|
-
|
|
908
|
+
window.removeEventListener("keydown", listener);
|
|
799
909
|
};
|
|
800
910
|
}, [
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
videoConfig
|
|
911
|
+
playbackRates,
|
|
912
|
+
keyboardSelectedRate,
|
|
913
|
+
setPlaybackRate,
|
|
914
|
+
setIsComponentVisible
|
|
806
915
|
]);
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
});
|
|
824
|
-
navigator.mediaSession.setActionHandler("seekto", (event) => {
|
|
825
|
-
if (browserMediaControlsBehavior.mode === "register-media-session" && event.seekTime !== undefined && videoConfig) {
|
|
826
|
-
seek(Math.round(event.seekTime * videoConfig.fps));
|
|
827
|
-
}
|
|
828
|
-
});
|
|
829
|
-
navigator.mediaSession.setActionHandler("seekbackward", () => {
|
|
830
|
-
if (browserMediaControlsBehavior.mode === "register-media-session" && videoConfig) {
|
|
831
|
-
seek(Math.max(0, Math.round(getCurrentFrame() - 10 * videoConfig.fps)));
|
|
832
|
-
}
|
|
833
|
-
});
|
|
834
|
-
navigator.mediaSession.setActionHandler("seekforward", () => {
|
|
835
|
-
if (browserMediaControlsBehavior.mode === "register-media-session" && videoConfig) {
|
|
836
|
-
seek(Math.min(videoConfig.durationInFrames - 1, Math.round(getCurrentFrame() + 10 * videoConfig.fps)));
|
|
837
|
-
}
|
|
838
|
-
});
|
|
839
|
-
navigator.mediaSession.setActionHandler("previoustrack", () => {
|
|
840
|
-
if (browserMediaControlsBehavior.mode === "register-media-session") {
|
|
841
|
-
seek(0);
|
|
842
|
-
}
|
|
843
|
-
});
|
|
844
|
-
return () => {
|
|
845
|
-
navigator.mediaSession.metadata = null;
|
|
846
|
-
navigator.mediaSession.setActionHandler("play", null);
|
|
847
|
-
navigator.mediaSession.setActionHandler("pause", null);
|
|
848
|
-
navigator.mediaSession.setActionHandler("seekto", null);
|
|
849
|
-
navigator.mediaSession.setActionHandler("seekbackward", null);
|
|
850
|
-
navigator.mediaSession.setActionHandler("seekforward", null);
|
|
851
|
-
navigator.mediaSession.setActionHandler("previoustrack", null);
|
|
916
|
+
const onSelect = useCallback3((rate) => {
|
|
917
|
+
setPlaybackRate(rate);
|
|
918
|
+
setIsComponentVisible(false);
|
|
919
|
+
}, [setIsComponentVisible, setPlaybackRate]);
|
|
920
|
+
const playbackPopup = useMemo3(() => {
|
|
921
|
+
return {
|
|
922
|
+
position: "absolute",
|
|
923
|
+
right: 0,
|
|
924
|
+
width: 125,
|
|
925
|
+
maxHeight: canvasSize.height - THRESHOLD - BOTTOM,
|
|
926
|
+
bottom: 35,
|
|
927
|
+
background: "#fff",
|
|
928
|
+
borderRadius: 4,
|
|
929
|
+
overflow: "auto",
|
|
930
|
+
color: "black",
|
|
931
|
+
textAlign: "left"
|
|
852
932
|
};
|
|
853
|
-
}, [
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
933
|
+
}, [canvasSize.height]);
|
|
934
|
+
return /* @__PURE__ */ jsx7("div", {
|
|
935
|
+
style: playbackPopup,
|
|
936
|
+
children: playbackRates.map((rate) => {
|
|
937
|
+
return /* @__PURE__ */ jsx7(PlaybackrateOption, {
|
|
938
|
+
selectedRate: playbackRate,
|
|
939
|
+
onSelect,
|
|
940
|
+
rate,
|
|
941
|
+
keyboardSelectedRate
|
|
942
|
+
}, rate);
|
|
943
|
+
})
|
|
944
|
+
});
|
|
861
945
|
};
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
shouldLoop
|
|
873
|
-
}) => {
|
|
874
|
-
const op = playbackSpeed < 0 ? Math.ceil : Math.floor;
|
|
875
|
-
const framesToAdvance = op(time * playbackSpeed / (1000 / fps)) - framesAdvanced;
|
|
876
|
-
const nextFrame = framesToAdvance + startFrame;
|
|
877
|
-
const isCurrentFrameOutside = startFrame > actualLastFrame || startFrame < actualFirstFrame;
|
|
878
|
-
const isNextFrameOutside = nextFrame > actualLastFrame || nextFrame < actualFirstFrame;
|
|
879
|
-
const hasEnded = !shouldLoop && isNextFrameOutside && !isCurrentFrameOutside;
|
|
880
|
-
if (playbackSpeed > 0) {
|
|
881
|
-
if (isNextFrameOutside) {
|
|
882
|
-
return {
|
|
883
|
-
nextFrame: actualFirstFrame,
|
|
884
|
-
framesToAdvance,
|
|
885
|
-
hasEnded
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
return { nextFrame, framesToAdvance, hasEnded };
|
|
889
|
-
}
|
|
890
|
-
if (isNextFrameOutside) {
|
|
891
|
-
return { nextFrame: actualLastFrame, framesToAdvance, hasEnded };
|
|
892
|
-
}
|
|
893
|
-
return { nextFrame, framesToAdvance, hasEnded };
|
|
946
|
+
var label = {
|
|
947
|
+
fontSize: 13,
|
|
948
|
+
fontWeight: "bold",
|
|
949
|
+
color: "white",
|
|
950
|
+
border: "2px solid white",
|
|
951
|
+
borderRadius: 20,
|
|
952
|
+
paddingLeft: 8,
|
|
953
|
+
paddingRight: 8,
|
|
954
|
+
paddingTop: 2,
|
|
955
|
+
paddingBottom: 2
|
|
894
956
|
};
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
957
|
+
var playerButtonStyle = {
|
|
958
|
+
appearance: "none",
|
|
959
|
+
backgroundColor: "transparent",
|
|
960
|
+
border: "none",
|
|
961
|
+
cursor: "pointer",
|
|
962
|
+
paddingLeft: 0,
|
|
963
|
+
paddingRight: 0,
|
|
964
|
+
paddingTop: 6,
|
|
965
|
+
paddingBottom: 6,
|
|
966
|
+
height: 37,
|
|
967
|
+
display: "inline-flex",
|
|
968
|
+
marginBottom: 0,
|
|
969
|
+
marginTop: 0,
|
|
970
|
+
alignItems: "center"
|
|
903
971
|
};
|
|
904
|
-
var
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
const onVisibilityChange = () => {
|
|
908
|
-
isBackgrounded.current = getIsBackgrounded();
|
|
909
|
-
};
|
|
910
|
-
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
911
|
-
return () => {
|
|
912
|
-
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
913
|
-
};
|
|
914
|
-
}, []);
|
|
915
|
-
return isBackgrounded;
|
|
972
|
+
var button = {
|
|
973
|
+
...playerButtonStyle,
|
|
974
|
+
position: "relative"
|
|
916
975
|
};
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
976
|
+
var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
|
|
977
|
+
const { ref, isComponentVisible, setIsComponentVisible } = useComponentVisible(false);
|
|
978
|
+
const { playbackRate } = Internals4.usePlaybackRate();
|
|
979
|
+
const onClick = useCallback3((e) => {
|
|
980
|
+
e.stopPropagation();
|
|
981
|
+
e.preventDefault();
|
|
982
|
+
setIsComponentVisible((prevIsComponentVisible) => !prevIsComponentVisible);
|
|
983
|
+
}, [setIsComponentVisible]);
|
|
984
|
+
return /* @__PURE__ */ jsx7("div", {
|
|
985
|
+
ref,
|
|
986
|
+
children: /* @__PURE__ */ jsxs5("button", {
|
|
987
|
+
type: "button",
|
|
988
|
+
"aria-label": "Change playback rate",
|
|
989
|
+
style: button,
|
|
990
|
+
onClick,
|
|
991
|
+
children: [
|
|
992
|
+
/* @__PURE__ */ jsxs5("div", {
|
|
993
|
+
style: label,
|
|
994
|
+
children: [
|
|
995
|
+
playbackRate,
|
|
996
|
+
"x"
|
|
997
|
+
]
|
|
998
|
+
}),
|
|
999
|
+
isComponentVisible && /* @__PURE__ */ jsx7(PlaybackPopup, {
|
|
1000
|
+
canvasSize,
|
|
1001
|
+
playbackRates,
|
|
1002
|
+
setIsComponentVisible
|
|
1003
|
+
})
|
|
1004
|
+
]
|
|
1005
|
+
})
|
|
1006
|
+
});
|
|
940
1007
|
};
|
|
941
1008
|
|
|
942
|
-
// src/
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1009
|
+
// src/PlayerSeekBar.tsx
|
|
1010
|
+
import { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo6, useRef as useRef4, useState as useState8 } from "react";
|
|
1011
|
+
import { Internals as Internals6, interpolate } from "remotion";
|
|
1012
|
+
|
|
1013
|
+
// src/use-player-methods.ts
|
|
1014
|
+
import { useCallback as useCallback4, useContext as useContext2, useMemo as useMemo4, useRef as useRef3 } from "react";
|
|
1015
|
+
import { Internals as Internals5, useRemotionEnvironment } from "remotion";
|
|
1016
|
+
var usePlayerMethods = () => {
|
|
1017
|
+
const seekFrame = Internals5.Timeline.useTimelineSeekFrame();
|
|
1018
|
+
const {
|
|
1019
|
+
setPlaying,
|
|
1020
|
+
frameRef,
|
|
1021
|
+
audioAndVideoTags,
|
|
1022
|
+
isPlaying: readIsPlaying,
|
|
1023
|
+
isBuffering
|
|
1024
|
+
} = useContext2(Internals5.SetTimelineContext);
|
|
1025
|
+
const audioContext = useContext2(Internals5.SharedAudioContext);
|
|
1026
|
+
const audioTagsContext = useContext2(Internals5.SharedAudioTagsContext);
|
|
1027
|
+
const { playerMuted, mediaVolume } = useContext2(Internals5.MediaVolumeContext);
|
|
1028
|
+
const muted = playerMuted || mediaVolume === 0;
|
|
1029
|
+
const environment = useRemotionEnvironment();
|
|
1030
|
+
const video = Internals5.useVideo();
|
|
1031
|
+
const videoId = video?.id ?? null;
|
|
1032
|
+
const videoDurationInFrames = video?.durationInFrames ?? null;
|
|
1033
|
+
const config = Internals5.useUnsafeVideoConfig();
|
|
1034
|
+
const emitter = useContext2(PlayerEventEmitterContext);
|
|
1035
|
+
const playStart = useRef3(0);
|
|
1036
|
+
const fallbackFrame = useRef3(null);
|
|
1037
|
+
const nextPlayIsAutoPlayAttempt = useRef3(false);
|
|
1038
|
+
if (!emitter) {
|
|
1039
|
+
throw new TypeError("Expected Player event emitter context");
|
|
949
1040
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
loop,
|
|
954
|
-
playbackRate,
|
|
955
|
-
moveToBeginningWhenEnded,
|
|
956
|
-
inFrame,
|
|
957
|
-
outFrame,
|
|
958
|
-
browserMediaControlsBehavior,
|
|
959
|
-
getCurrentFrame,
|
|
960
|
-
muted
|
|
961
|
-
}) => {
|
|
962
|
-
const config = Internals6.useUnsafeVideoConfig();
|
|
963
|
-
const fps = config?.fps ?? null;
|
|
964
|
-
const durationInFrames = config?.durationInFrames ?? null;
|
|
965
|
-
const compositionId = config?.id ?? null;
|
|
966
|
-
const frame = Internals6.Timeline.useTimelinePosition();
|
|
967
|
-
const playing = Internals6.usePlaying();
|
|
968
|
-
const { pause, emitter, isPlaying } = usePlayerMethods();
|
|
969
|
-
const setFrameFromPlayback = Internals6.Timeline.useTimelineSetFrameWithoutSeek();
|
|
970
|
-
const sharedAudioContext = useContext3(Internals6.SharedAudioContext);
|
|
971
|
-
const { setPlayerMuted } = useContext3(Internals6.SetMediaVolumeContext);
|
|
972
|
-
const { isBuffering, subscribeBuffering, seek } = useContext3(Internals6.SetTimelineContext);
|
|
973
|
-
const logLevel = Internals6.useLogLevel();
|
|
974
|
-
const isBackgroundedRef = useIsBackgrounded();
|
|
975
|
-
const lastTimeUpdateTimestamp = useRef4(0);
|
|
976
|
-
const playbackClockRef = useRef4(null);
|
|
977
|
-
const previousMutedRef = useRef4(muted);
|
|
978
|
-
const anchoredAudioContextRef = useRef4(null);
|
|
979
|
-
useBrowserMediaSession({
|
|
980
|
-
browserMediaControlsBehavior,
|
|
981
|
-
playbackRate,
|
|
982
|
-
videoConfig: config
|
|
983
|
-
});
|
|
984
|
-
useLayoutEffect2(() => {
|
|
985
|
-
if (!sharedAudioContext) {
|
|
986
|
-
return;
|
|
1041
|
+
const getCurrentFrame = useCallback4(() => {
|
|
1042
|
+
if (videoId === null || videoDurationInFrames === null) {
|
|
1043
|
+
return fallbackFrame.current ?? (typeof window === "undefined" ? 0 : window.remotion_initialFrame ?? 0);
|
|
987
1044
|
}
|
|
988
|
-
|
|
989
|
-
|
|
1045
|
+
const unclamped = frameRef.current[videoId] ?? (environment.isPlayer ? 0 : Internals5.Timeline.getFrameForComposition(videoId));
|
|
1046
|
+
return Internals5.Timeline.clampFrameToCompositionRange(unclamped, videoDurationInFrames);
|
|
1047
|
+
}, [environment.isPlayer, frameRef, videoId, videoDurationInFrames]);
|
|
1048
|
+
const seek = useCallback4((newFrame) => {
|
|
1049
|
+
const frameToSeekTo = config ? Internals5.TimelinePosition.clampFrameToCompositionRange(newFrame, config.durationInFrames) : Math.max(0, newFrame);
|
|
1050
|
+
fallbackFrame.current = frameToSeekTo;
|
|
1051
|
+
if (video?.id) {
|
|
1052
|
+
seekFrame((currentFrames) => currentFrames[video.id] === frameToSeekTo ? currentFrames : { ...currentFrames, [video.id]: frameToSeekTo });
|
|
1053
|
+
if (frameRef.current[video.id] !== frameToSeekTo) {
|
|
1054
|
+
frameRef.current = {
|
|
1055
|
+
...frameRef.current,
|
|
1056
|
+
[video.id]: frameToSeekTo
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
990
1059
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1060
|
+
emitter.dispatchSeek(frameToSeekTo);
|
|
1061
|
+
}, [config, emitter, frameRef, seekFrame, video?.id]);
|
|
1062
|
+
const play = useCallback4((e) => {
|
|
1063
|
+
const isAutoPlayAttempt = nextPlayIsAutoPlayAttempt.current;
|
|
1064
|
+
nextPlayIsAutoPlayAttempt.current = false;
|
|
1065
|
+
if (readIsPlaying()) {
|
|
995
1066
|
return;
|
|
996
1067
|
}
|
|
997
|
-
const
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
absoluteTimeInSeconds: frame / fps,
|
|
1001
|
-
globalPlaybackRate: playbackRate,
|
|
1002
|
-
logLevel,
|
|
1003
|
-
force: false
|
|
1004
|
-
});
|
|
1005
|
-
if (changed) {
|
|
1006
|
-
sharedAudioContext.audioSyncAnchorEmitter.dispatch("changed");
|
|
1068
|
+
const lastFrameForPlayback = (config?.durationInFrames ?? 1) - 1;
|
|
1069
|
+
if (getCurrentFrame() === lastFrameForPlayback) {
|
|
1070
|
+
seek(0);
|
|
1007
1071
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1072
|
+
if (!muted) {
|
|
1073
|
+
if (isAutoPlayAttempt) {
|
|
1074
|
+
audioContext?.resumeAsAutoPlay();
|
|
1075
|
+
} else {
|
|
1076
|
+
audioContext?.resume();
|
|
1077
|
+
}
|
|
1078
|
+
if (audioTagsContext && audioTagsContext.numberOfAudioTags > 0 && e) {
|
|
1079
|
+
audioTagsContext.playAllAudios();
|
|
1080
|
+
}
|
|
1013
1081
|
}
|
|
1014
|
-
|
|
1082
|
+
audioAndVideoTags.current.forEach((tag) => tag.play("player play() was called and playing audio from a click"));
|
|
1083
|
+
setPlaying(true);
|
|
1084
|
+
playStart.current = getCurrentFrame();
|
|
1085
|
+
emitter.dispatchPlay();
|
|
1086
|
+
}, [
|
|
1087
|
+
audioAndVideoTags,
|
|
1088
|
+
audioContext,
|
|
1089
|
+
audioTagsContext,
|
|
1090
|
+
config?.durationInFrames,
|
|
1091
|
+
emitter,
|
|
1092
|
+
getCurrentFrame,
|
|
1093
|
+
muted,
|
|
1094
|
+
readIsPlaying,
|
|
1095
|
+
seek,
|
|
1096
|
+
setPlaying
|
|
1097
|
+
]);
|
|
1098
|
+
const playAsAutoPlay = useCallback4(() => {
|
|
1099
|
+
nextPlayIsAutoPlayAttempt.current = true;
|
|
1100
|
+
play();
|
|
1101
|
+
}, [play]);
|
|
1102
|
+
const pause = useCallback4(() => {
|
|
1103
|
+
if (readIsPlaying()) {
|
|
1104
|
+
setPlaying(false);
|
|
1105
|
+
emitter.dispatchPause();
|
|
1106
|
+
audioContext?.suspend();
|
|
1107
|
+
}
|
|
1108
|
+
}, [audioContext, emitter, readIsPlaying, setPlaying]);
|
|
1109
|
+
const pauseAndReturnToPlayStart = useCallback4(() => {
|
|
1110
|
+
if (readIsPlaying()) {
|
|
1111
|
+
setPlaying(false);
|
|
1112
|
+
fallbackFrame.current = playStart.current;
|
|
1113
|
+
if (config) {
|
|
1114
|
+
seekFrame((currentFrames) => ({
|
|
1115
|
+
...currentFrames,
|
|
1116
|
+
[config.id]: playStart.current
|
|
1117
|
+
}));
|
|
1118
|
+
frameRef.current = {
|
|
1119
|
+
...frameRef.current,
|
|
1120
|
+
[config.id]: playStart.current
|
|
1121
|
+
};
|
|
1122
|
+
emitter.dispatchPause();
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
}, [config, emitter, frameRef, readIsPlaying, setPlaying, seekFrame]);
|
|
1126
|
+
const lastFrame = (config?.durationInFrames ?? 1) - 1;
|
|
1127
|
+
const frameBack = useCallback4((frames) => {
|
|
1128
|
+
if (!videoId) {
|
|
1129
|
+
return null;
|
|
1130
|
+
}
|
|
1131
|
+
if (readIsPlaying()) {
|
|
1015
1132
|
return;
|
|
1016
1133
|
}
|
|
1017
|
-
|
|
1134
|
+
const previousFrame = frameRef.current[videoId] ?? window.remotion_initialFrame ?? 0;
|
|
1135
|
+
const newFrame = Math.max(0, previousFrame - frames);
|
|
1136
|
+
if (previousFrame === newFrame) {
|
|
1018
1137
|
return;
|
|
1019
1138
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
audioContext,
|
|
1025
|
-
audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
|
|
1026
|
-
absoluteTimeInSeconds: getCurrentFrame() / fps,
|
|
1027
|
-
globalPlaybackRate: playbackRate,
|
|
1028
|
-
logLevel,
|
|
1029
|
-
force: true
|
|
1030
|
-
});
|
|
1031
|
-
if (changed) {
|
|
1032
|
-
sharedAudioContext.audioSyncAnchorEmitter.dispatch("changed");
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
};
|
|
1036
|
-
audioContext?.addEventListener("statechange", callback);
|
|
1037
|
-
return () => {
|
|
1038
|
-
audioContext?.removeEventListener("statechange", callback);
|
|
1139
|
+
seekFrame((currentFrames) => currentFrames[videoId] === newFrame ? currentFrames : { ...currentFrames, [videoId]: newFrame });
|
|
1140
|
+
frameRef.current = {
|
|
1141
|
+
...frameRef.current,
|
|
1142
|
+
[videoId]: newFrame
|
|
1039
1143
|
};
|
|
1040
|
-
}, [
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1144
|
+
}, [frameRef, readIsPlaying, seekFrame, videoId]);
|
|
1145
|
+
const frameForward = useCallback4((frames) => {
|
|
1146
|
+
if (!videoId) {
|
|
1147
|
+
return null;
|
|
1148
|
+
}
|
|
1149
|
+
if (readIsPlaying()) {
|
|
1046
1150
|
return;
|
|
1047
1151
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1152
|
+
const previousFrame = frameRef.current[videoId] ?? window.remotion_initialFrame ?? 0;
|
|
1153
|
+
const newFrame = Math.min(lastFrame, previousFrame + frames);
|
|
1154
|
+
if (previousFrame === newFrame) {
|
|
1051
1155
|
return;
|
|
1052
1156
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1157
|
+
seekFrame((currentFrames) => currentFrames[videoId] === newFrame ? currentFrames : { ...currentFrames, [videoId]: newFrame });
|
|
1158
|
+
frameRef.current = {
|
|
1159
|
+
...frameRef.current,
|
|
1160
|
+
[videoId]: newFrame
|
|
1161
|
+
};
|
|
1162
|
+
}, [frameRef, lastFrame, readIsPlaying, seekFrame, videoId]);
|
|
1163
|
+
const toggle = useCallback4((e) => {
|
|
1164
|
+
if (readIsPlaying()) {
|
|
1165
|
+
pause();
|
|
1166
|
+
} else {
|
|
1167
|
+
play(e);
|
|
1055
1168
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1169
|
+
}, [pause, play, readIsPlaying]);
|
|
1170
|
+
return useMemo4(() => {
|
|
1171
|
+
return {
|
|
1172
|
+
frameBack,
|
|
1173
|
+
frameForward,
|
|
1174
|
+
emitter,
|
|
1175
|
+
play,
|
|
1176
|
+
playAsAutoPlay,
|
|
1177
|
+
pause,
|
|
1178
|
+
seek,
|
|
1179
|
+
getCurrentFrame,
|
|
1180
|
+
isPlaying: readIsPlaying,
|
|
1181
|
+
isBuffering,
|
|
1182
|
+
pauseAndReturnToPlayStart,
|
|
1183
|
+
toggle
|
|
1184
|
+
};
|
|
1185
|
+
}, [
|
|
1186
|
+
emitter,
|
|
1187
|
+
frameBack,
|
|
1188
|
+
frameForward,
|
|
1189
|
+
getCurrentFrame,
|
|
1190
|
+
readIsPlaying,
|
|
1191
|
+
pause,
|
|
1192
|
+
pauseAndReturnToPlayStart,
|
|
1193
|
+
play,
|
|
1194
|
+
playAsAutoPlay,
|
|
1195
|
+
isBuffering,
|
|
1196
|
+
seek,
|
|
1197
|
+
toggle
|
|
1198
|
+
]);
|
|
1199
|
+
};
|
|
1200
|
+
|
|
1201
|
+
// src/utils/use-element-size.ts
|
|
1202
|
+
import { useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo5, useState as useState7 } from "react";
|
|
1203
|
+
var elementSizeHooks = [];
|
|
1204
|
+
var updateAllElementsSizes = () => {
|
|
1205
|
+
for (const listener of elementSizeHooks) {
|
|
1206
|
+
listener();
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
var getElement = (source) => {
|
|
1210
|
+
if (!source) {
|
|
1211
|
+
return null;
|
|
1212
|
+
}
|
|
1213
|
+
if ("current" in source) {
|
|
1214
|
+
return source.current;
|
|
1215
|
+
}
|
|
1216
|
+
return source;
|
|
1217
|
+
};
|
|
1218
|
+
var useElementSize = (source, options) => {
|
|
1219
|
+
const [size, setSize] = useState7(() => {
|
|
1220
|
+
const element = getElement(source);
|
|
1221
|
+
if (!element) {
|
|
1222
|
+
return null;
|
|
1082
1223
|
}
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1224
|
+
const rect = element.getClientRects();
|
|
1225
|
+
if (!rect[0]) {
|
|
1226
|
+
return null;
|
|
1227
|
+
}
|
|
1228
|
+
return {
|
|
1229
|
+
width: rect[0].width,
|
|
1230
|
+
height: rect[0].height,
|
|
1231
|
+
left: rect[0].x,
|
|
1232
|
+
top: rect[0].y,
|
|
1233
|
+
windowSize: {
|
|
1234
|
+
height: window.innerHeight,
|
|
1235
|
+
width: window.innerWidth
|
|
1095
1236
|
}
|
|
1096
1237
|
};
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
if (!
|
|
1106
|
-
|
|
1107
|
-
return;
|
|
1108
|
-
}
|
|
1109
|
-
if (!muted && !audioContextFailed && !isBuffering()) {
|
|
1110
|
-
sharedAudioContext?.resume?.();
|
|
1111
|
-
}
|
|
1112
|
-
const time = performance.now() - clock.startedTime;
|
|
1113
|
-
const actualLastFrame = outFrame ?? durationInFrames - 1;
|
|
1114
|
-
const actualFirstFrame = inFrame ?? 0;
|
|
1115
|
-
const seekRevision = seek?.revision.current ?? null;
|
|
1116
|
-
if (seekRevision !== lastSeekRevision) {
|
|
1117
|
-
playbackFrame = getCurrentFrame();
|
|
1118
|
-
lastSeekRevision = seekRevision;
|
|
1119
|
-
}
|
|
1120
|
-
const currentFrame = playbackFrame;
|
|
1121
|
-
const { nextFrame, framesToAdvance, hasEnded } = calculateNextFrame({
|
|
1122
|
-
time,
|
|
1123
|
-
currentFrame,
|
|
1124
|
-
playbackSpeed: playbackRate,
|
|
1125
|
-
fps,
|
|
1126
|
-
actualFirstFrame,
|
|
1127
|
-
actualLastFrame,
|
|
1128
|
-
framesAdvanced: clock.framesAdvanced,
|
|
1129
|
-
shouldLoop: loop
|
|
1130
|
-
});
|
|
1131
|
-
clock.framesAdvanced += framesToAdvance;
|
|
1132
|
-
const frameToDisplay = hasEnded && !moveToBeginningWhenEnded ? playbackRate > 0 ? actualLastFrame : actualFirstFrame : nextFrame;
|
|
1133
|
-
if (frameToDisplay !== currentFrame && !isBuffering()) {
|
|
1134
|
-
playbackFrame = frameToDisplay;
|
|
1135
|
-
setFrameFromPlayback((c) => ({ ...c, [compositionId]: frameToDisplay }));
|
|
1136
|
-
}
|
|
1137
|
-
if (hasEnded) {
|
|
1138
|
-
stop();
|
|
1139
|
-
pause();
|
|
1140
|
-
emitter.dispatchEnded();
|
|
1141
|
-
return;
|
|
1142
|
-
}
|
|
1143
|
-
queueNextFrame();
|
|
1144
|
-
};
|
|
1145
|
-
const queueNextFrame = () => {
|
|
1146
|
-
if (hasBeenStopped) {
|
|
1147
|
-
return;
|
|
1148
|
-
}
|
|
1149
|
-
const getIsResumingAudioContext = audioContextFailed ? null : sharedAudioContext?.getIsResumingAudioContext?.() ?? null;
|
|
1150
|
-
if (getIsResumingAudioContext !== null && !muted) {
|
|
1151
|
-
getIsResumingAudioContext.then((result) => {
|
|
1152
|
-
if (hasBeenStopped) {
|
|
1153
|
-
return;
|
|
1154
|
-
}
|
|
1155
|
-
if (result === "failed") {
|
|
1156
|
-
audioContextFailed = true;
|
|
1157
|
-
sharedAudioContext?.suspend();
|
|
1158
|
-
setPlayerMuted(true);
|
|
1159
|
-
}
|
|
1160
|
-
clock.startedTime = performance.now();
|
|
1161
|
-
clock.framesAdvanced = 0;
|
|
1162
|
-
queueNextFrame();
|
|
1163
|
-
});
|
|
1164
|
-
return;
|
|
1165
|
-
}
|
|
1166
|
-
if (isBuffering()) {
|
|
1167
|
-
if (!muted && !audioContextFailed) {
|
|
1168
|
-
sharedAudioContext?.suspend?.();
|
|
1169
|
-
}
|
|
1170
|
-
const unsubscribe = subscribeBuffering((state) => {
|
|
1171
|
-
if (state.buffering) {
|
|
1172
|
-
return;
|
|
1173
|
-
}
|
|
1174
|
-
unsubscribe();
|
|
1175
|
-
if (!muted && !audioContextFailed && sharedAudioContext?._experimentalKeepAudioContextAlive) {
|
|
1176
|
-
sharedAudioContext.resume();
|
|
1177
|
-
}
|
|
1178
|
-
clock.startedTime = performance.now();
|
|
1179
|
-
clock.framesAdvanced = 0;
|
|
1180
|
-
queueNextFrame();
|
|
1181
|
-
});
|
|
1182
|
-
return;
|
|
1183
|
-
}
|
|
1184
|
-
if (isBackgroundedRef.current) {
|
|
1185
|
-
reqAnimFrameCall = {
|
|
1186
|
-
type: "timeout",
|
|
1187
|
-
id: setTimeout(callback, 1000 / fps)
|
|
1188
|
-
};
|
|
1189
|
-
return;
|
|
1190
|
-
}
|
|
1191
|
-
reqAnimFrameCall = { type: "raf", id: requestAnimationFrame(callback) };
|
|
1192
|
-
};
|
|
1193
|
-
queueNextFrame();
|
|
1194
|
-
const onVisibilityChange = () => {
|
|
1195
|
-
if (document.visibilityState === "visible") {
|
|
1196
|
-
return;
|
|
1197
|
-
}
|
|
1198
|
-
cancelQueuedFrame();
|
|
1199
|
-
callback();
|
|
1200
|
-
};
|
|
1201
|
-
window.addEventListener("visibilitychange", onVisibilityChange);
|
|
1202
|
-
return () => {
|
|
1203
|
-
window.removeEventListener("visibilitychange", onVisibilityChange);
|
|
1204
|
-
stop();
|
|
1205
|
-
};
|
|
1206
|
-
}, [
|
|
1207
|
-
compositionId,
|
|
1208
|
-
durationInFrames,
|
|
1209
|
-
fps,
|
|
1210
|
-
loop,
|
|
1211
|
-
pause,
|
|
1212
|
-
playing,
|
|
1213
|
-
setFrameFromPlayback,
|
|
1214
|
-
emitter,
|
|
1215
|
-
playbackRate,
|
|
1216
|
-
inFrame,
|
|
1217
|
-
outFrame,
|
|
1218
|
-
moveToBeginningWhenEnded,
|
|
1219
|
-
isBackgroundedRef,
|
|
1220
|
-
getCurrentFrame,
|
|
1221
|
-
isBuffering,
|
|
1222
|
-
isPlaying,
|
|
1223
|
-
sharedAudioContext,
|
|
1224
|
-
setPlayerMuted,
|
|
1225
|
-
subscribeBuffering,
|
|
1226
|
-
seek,
|
|
1227
|
-
logLevel,
|
|
1228
|
-
muted
|
|
1229
|
-
]);
|
|
1230
|
-
useEffect5(() => {
|
|
1231
|
-
const now = performance.now();
|
|
1232
|
-
const timeSinceLastUpdate = now - lastTimeUpdateTimestamp.current;
|
|
1233
|
-
if (timeSinceLastUpdate >= 250) {
|
|
1234
|
-
emitter.dispatchTimeUpdate({ frame });
|
|
1235
|
-
lastTimeUpdateTimestamp.current = now;
|
|
1236
|
-
return;
|
|
1237
|
-
}
|
|
1238
|
-
const timeoutId = setTimeout(() => {
|
|
1239
|
-
emitter.dispatchTimeUpdate({ frame });
|
|
1240
|
-
lastTimeUpdateTimestamp.current = performance.now();
|
|
1241
|
-
}, 250 - timeSinceLastUpdate);
|
|
1242
|
-
return () => clearTimeout(timeoutId);
|
|
1243
|
-
}, [emitter, frame]);
|
|
1244
|
-
useEffect5(() => {
|
|
1245
|
-
emitter.dispatchFrameUpdate({ frame });
|
|
1246
|
-
}, [emitter, frame]);
|
|
1247
|
-
};
|
|
1248
|
-
|
|
1249
|
-
// src/utils/use-element-size.ts
|
|
1250
|
-
import { useCallback as useCallback2, useEffect as useEffect6, useMemo as useMemo2, useState as useState3 } from "react";
|
|
1251
|
-
var elementSizeHooks = [];
|
|
1252
|
-
var updateAllElementsSizes = () => {
|
|
1253
|
-
for (const listener of elementSizeHooks) {
|
|
1254
|
-
listener();
|
|
1255
|
-
}
|
|
1256
|
-
};
|
|
1257
|
-
var getElement = (source) => {
|
|
1258
|
-
if (!source) {
|
|
1259
|
-
return null;
|
|
1260
|
-
}
|
|
1261
|
-
if ("current" in source) {
|
|
1262
|
-
return source.current;
|
|
1263
|
-
}
|
|
1264
|
-
return source;
|
|
1265
|
-
};
|
|
1266
|
-
var useElementSize = (source, options) => {
|
|
1267
|
-
const [size, setSize] = useState3(() => {
|
|
1268
|
-
const element = getElement(source);
|
|
1269
|
-
if (!element) {
|
|
1270
|
-
return null;
|
|
1271
|
-
}
|
|
1272
|
-
const rect = element.getClientRects();
|
|
1273
|
-
if (!rect[0]) {
|
|
1274
|
-
return null;
|
|
1275
|
-
}
|
|
1276
|
-
return {
|
|
1277
|
-
width: rect[0].width,
|
|
1278
|
-
height: rect[0].height,
|
|
1279
|
-
left: rect[0].x,
|
|
1280
|
-
top: rect[0].y,
|
|
1281
|
-
windowSize: {
|
|
1282
|
-
height: window.innerHeight,
|
|
1283
|
-
width: window.innerWidth
|
|
1284
|
-
}
|
|
1285
|
-
};
|
|
1286
|
-
});
|
|
1287
|
-
const observer = useMemo2(() => {
|
|
1288
|
-
if (typeof ResizeObserver === "undefined") {
|
|
1289
|
-
return null;
|
|
1290
|
-
}
|
|
1291
|
-
return new ResizeObserver((entries) => {
|
|
1292
|
-
const { contentRect, target } = entries[0];
|
|
1293
|
-
const newSize = target.getClientRects();
|
|
1294
|
-
if (!newSize?.[0]) {
|
|
1295
|
-
setSize(null);
|
|
1238
|
+
});
|
|
1239
|
+
const observer = useMemo5(() => {
|
|
1240
|
+
if (typeof ResizeObserver === "undefined") {
|
|
1241
|
+
return null;
|
|
1242
|
+
}
|
|
1243
|
+
return new ResizeObserver((entries) => {
|
|
1244
|
+
const { contentRect, target } = entries[0];
|
|
1245
|
+
const newSize = target.getClientRects();
|
|
1246
|
+
if (!newSize?.[0]) {
|
|
1247
|
+
setSize(null);
|
|
1296
1248
|
return;
|
|
1297
1249
|
}
|
|
1298
1250
|
const probableCssParentScaleX = contentRect.width === 0 ? 1 : newSize[0].width / contentRect.width;
|
|
@@ -1317,7 +1269,7 @@ var useElementSize = (source, options) => {
|
|
|
1317
1269
|
});
|
|
1318
1270
|
});
|
|
1319
1271
|
}, [options.shouldApplyCssTransforms]);
|
|
1320
|
-
const updateSize =
|
|
1272
|
+
const updateSize = useCallback5(() => {
|
|
1321
1273
|
const element = getElement(source);
|
|
1322
1274
|
if (!element) {
|
|
1323
1275
|
return;
|
|
@@ -1344,10 +1296,10 @@ var useElementSize = (source, options) => {
|
|
|
1344
1296
|
};
|
|
1345
1297
|
});
|
|
1346
1298
|
}, [source]);
|
|
1347
|
-
|
|
1299
|
+
useEffect5(() => {
|
|
1348
1300
|
updateSize();
|
|
1349
1301
|
}, [updateSize]);
|
|
1350
|
-
|
|
1302
|
+
useEffect5(() => {
|
|
1351
1303
|
if (!observer) {
|
|
1352
1304
|
return;
|
|
1353
1305
|
}
|
|
@@ -1361,7 +1313,7 @@ var useElementSize = (source, options) => {
|
|
|
1361
1313
|
}
|
|
1362
1314
|
};
|
|
1363
1315
|
}, [observer, source]);
|
|
1364
|
-
|
|
1316
|
+
useEffect5(() => {
|
|
1365
1317
|
if (!options.triggerOnWindowResize) {
|
|
1366
1318
|
return;
|
|
1367
1319
|
}
|
|
@@ -1370,13 +1322,13 @@ var useElementSize = (source, options) => {
|
|
|
1370
1322
|
window.removeEventListener("resize", updateSize);
|
|
1371
1323
|
};
|
|
1372
1324
|
}, [options.triggerOnWindowResize, updateSize]);
|
|
1373
|
-
|
|
1325
|
+
useEffect5(() => {
|
|
1374
1326
|
elementSizeHooks.push(updateSize);
|
|
1375
1327
|
return () => {
|
|
1376
1328
|
elementSizeHooks = elementSizeHooks.filter((e) => e !== updateSize);
|
|
1377
1329
|
};
|
|
1378
1330
|
}, [updateSize]);
|
|
1379
|
-
return
|
|
1331
|
+
return useMemo5(() => {
|
|
1380
1332
|
if (!size) {
|
|
1381
1333
|
return null;
|
|
1382
1334
|
}
|
|
@@ -1384,1134 +1336,1182 @@ var useElementSize = (source, options) => {
|
|
|
1384
1336
|
}, [size, updateSize]);
|
|
1385
1337
|
};
|
|
1386
1338
|
|
|
1387
|
-
// src/
|
|
1388
|
-
import
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
useState as useState12
|
|
1397
|
-
} from "react";
|
|
1398
|
-
import { Composition, Internals as Internals15 } from "remotion";
|
|
1399
|
-
import { NoReactInternals as NoReactInternals2 } from "remotion/no-react";
|
|
1400
|
-
|
|
1401
|
-
// src/player-css-classname.ts
|
|
1402
|
-
var playerCssClassname = (override) => {
|
|
1403
|
-
return override ?? "__remotion-player";
|
|
1339
|
+
// src/PlayerSeekBar.tsx
|
|
1340
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1341
|
+
var getFrameFromX = (clientX, durationInFrames, width) => {
|
|
1342
|
+
const pos = clientX;
|
|
1343
|
+
const frame = Math.round(interpolate(pos, [0, width], [0, durationInFrames - 1], {
|
|
1344
|
+
extrapolateLeft: "clamp",
|
|
1345
|
+
extrapolateRight: "clamp"
|
|
1346
|
+
}));
|
|
1347
|
+
return frame;
|
|
1404
1348
|
};
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
} from "react";
|
|
1418
|
-
import { Internals as Internals11 } from "remotion";
|
|
1419
|
-
|
|
1420
|
-
// src/error-boundary.tsx
|
|
1421
|
-
import React4 from "react";
|
|
1422
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1423
|
-
var errorStyle = {
|
|
1424
|
-
display: "flex",
|
|
1425
|
-
justifyContent: "center",
|
|
1426
|
-
alignItems: "center",
|
|
1427
|
-
flex: 1,
|
|
1428
|
-
height: "100%",
|
|
1429
|
-
width: "100%"
|
|
1349
|
+
var BAR_HEIGHT2 = 5;
|
|
1350
|
+
var KNOB_SIZE2 = 12;
|
|
1351
|
+
var VERTICAL_PADDING = 4;
|
|
1352
|
+
var containerStyle = {
|
|
1353
|
+
userSelect: "none",
|
|
1354
|
+
WebkitUserSelect: "none",
|
|
1355
|
+
paddingTop: VERTICAL_PADDING,
|
|
1356
|
+
paddingBottom: VERTICAL_PADDING,
|
|
1357
|
+
boxSizing: "border-box",
|
|
1358
|
+
cursor: "pointer",
|
|
1359
|
+
position: "relative",
|
|
1360
|
+
touchAction: "none"
|
|
1430
1361
|
};
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
}
|
|
1437
|
-
componentDidCatch(error) {
|
|
1438
|
-
this.props.onError(error);
|
|
1439
|
-
}
|
|
1440
|
-
render() {
|
|
1441
|
-
if (this.state.hasError) {
|
|
1442
|
-
return /* @__PURE__ */ jsx4("div", {
|
|
1443
|
-
style: errorStyle,
|
|
1444
|
-
children: this.props.errorFallback({
|
|
1445
|
-
error: this.state.hasError
|
|
1446
|
-
})
|
|
1447
|
-
});
|
|
1448
|
-
}
|
|
1449
|
-
return this.props.children;
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
// src/license-blacklist.tsx
|
|
1454
|
-
import React5, { useEffect as useEffect7 } from "react";
|
|
1455
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1456
|
-
var getHashOfDomain = async () => {
|
|
1457
|
-
if (typeof window === "undefined") {
|
|
1458
|
-
return null;
|
|
1459
|
-
}
|
|
1460
|
-
if (typeof window.crypto === "undefined") {
|
|
1461
|
-
return null;
|
|
1462
|
-
}
|
|
1463
|
-
if (typeof window.crypto.subtle === "undefined") {
|
|
1464
|
-
return null;
|
|
1465
|
-
}
|
|
1466
|
-
try {
|
|
1467
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(window.location.hostname));
|
|
1468
|
-
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1469
|
-
} catch {
|
|
1470
|
-
return null;
|
|
1471
|
-
}
|
|
1362
|
+
var barBackground = {
|
|
1363
|
+
height: BAR_HEIGHT2,
|
|
1364
|
+
backgroundColor: "rgba(255, 255, 255, 0.25)",
|
|
1365
|
+
width: "100%",
|
|
1366
|
+
borderRadius: BAR_HEIGHT2 / 2
|
|
1472
1367
|
};
|
|
1473
|
-
var
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1368
|
+
var findBodyInWhichDivIsLocated = (div) => {
|
|
1369
|
+
let current = div;
|
|
1370
|
+
while (current.parentElement) {
|
|
1371
|
+
current = current.parentElement;
|
|
1372
|
+
}
|
|
1373
|
+
return current;
|
|
1478
1374
|
};
|
|
1479
|
-
var
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1375
|
+
var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFrame }) => {
|
|
1376
|
+
const containerRef = useRef4(null);
|
|
1377
|
+
const barHovered = useHoverState(containerRef, false);
|
|
1378
|
+
const size = useElementSize(containerRef, {
|
|
1379
|
+
triggerOnWindowResize: true,
|
|
1380
|
+
shouldApplyCssTransforms: true
|
|
1381
|
+
});
|
|
1382
|
+
const { seek, play, pause, isPlaying } = usePlayerMethods();
|
|
1383
|
+
const frame = Internals6.Timeline.useTimelinePosition();
|
|
1384
|
+
const [dragging, setDragging] = useState8({
|
|
1385
|
+
dragging: false
|
|
1386
|
+
});
|
|
1387
|
+
const width = size?.width ?? 0;
|
|
1388
|
+
const onPointerDown = useCallback6((e) => {
|
|
1389
|
+
if (e.button !== 0) {
|
|
1492
1390
|
return;
|
|
1493
1391
|
}
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1392
|
+
const posLeft = containerRef.current?.getBoundingClientRect().left;
|
|
1393
|
+
const _frame = getFrameFromX(e.clientX - posLeft, durationInFrames, width);
|
|
1394
|
+
const wasPlaying = isPlaying();
|
|
1395
|
+
pause();
|
|
1396
|
+
seek(_frame);
|
|
1397
|
+
setDragging({
|
|
1398
|
+
dragging: true,
|
|
1399
|
+
wasPlaying
|
|
1400
|
+
});
|
|
1401
|
+
onSeekStart();
|
|
1402
|
+
}, [durationInFrames, width, isPlaying, pause, seek, onSeekStart]);
|
|
1403
|
+
const onPointerMove = useCallback6((e) => {
|
|
1404
|
+
if (!size) {
|
|
1405
|
+
throw new Error("Player has no size");
|
|
1406
|
+
}
|
|
1407
|
+
if (!dragging.dragging) {
|
|
1503
1408
|
return;
|
|
1504
1409
|
}
|
|
1505
|
-
const
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1410
|
+
const posLeft = containerRef.current?.getBoundingClientRect().left;
|
|
1411
|
+
const _frame = getFrameFromX(e.clientX - posLeft, durationInFrames, size.width);
|
|
1412
|
+
seek(_frame);
|
|
1413
|
+
}, [dragging.dragging, durationInFrames, seek, size]);
|
|
1414
|
+
const onPointerUp = useCallback6(() => {
|
|
1415
|
+
setDragging({
|
|
1416
|
+
dragging: false
|
|
1417
|
+
});
|
|
1418
|
+
if (!dragging.dragging) {
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
if (dragging.wasPlaying) {
|
|
1422
|
+
play();
|
|
1423
|
+
} else {
|
|
1424
|
+
pause();
|
|
1425
|
+
}
|
|
1426
|
+
onSeekEnd();
|
|
1427
|
+
}, [dragging, onSeekEnd, pause, play]);
|
|
1428
|
+
useEffect6(() => {
|
|
1429
|
+
if (!dragging.dragging) {
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
const body = findBodyInWhichDivIsLocated(containerRef.current);
|
|
1433
|
+
body.addEventListener("pointermove", onPointerMove);
|
|
1434
|
+
body.addEventListener("pointerup", onPointerUp);
|
|
1524
1435
|
return () => {
|
|
1525
|
-
|
|
1436
|
+
body.removeEventListener("pointermove", onPointerMove);
|
|
1437
|
+
body.removeEventListener("pointerup", onPointerUp);
|
|
1526
1438
|
};
|
|
1527
|
-
}, [
|
|
1528
|
-
|
|
1529
|
-
return
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1439
|
+
}, [dragging.dragging, onPointerMove, onPointerUp]);
|
|
1440
|
+
const knobStyle = useMemo6(() => {
|
|
1441
|
+
return {
|
|
1442
|
+
height: KNOB_SIZE2,
|
|
1443
|
+
width: KNOB_SIZE2,
|
|
1444
|
+
borderRadius: KNOB_SIZE2 / 2,
|
|
1445
|
+
position: "absolute",
|
|
1446
|
+
top: VERTICAL_PADDING - KNOB_SIZE2 / 2 + 5 / 2,
|
|
1447
|
+
backgroundColor: "white",
|
|
1448
|
+
left: Math.max(0, frame / Math.max(1, durationInFrames - 1) * width - KNOB_SIZE2 / 2),
|
|
1449
|
+
boxShadow: "0 0 2px black",
|
|
1450
|
+
opacity: Number(barHovered || dragging.dragging)
|
|
1451
|
+
};
|
|
1452
|
+
}, [barHovered, dragging.dragging, durationInFrames, frame, width]);
|
|
1453
|
+
const fillStyle = useMemo6(() => {
|
|
1454
|
+
return {
|
|
1455
|
+
height: BAR_HEIGHT2,
|
|
1456
|
+
backgroundColor: "rgba(255, 255, 255, 1)",
|
|
1457
|
+
width: (frame - (inFrame ?? 0)) / (durationInFrames - 1) * width,
|
|
1458
|
+
marginLeft: (inFrame ?? 0) / (durationInFrames - 1) * width,
|
|
1459
|
+
borderRadius: BAR_HEIGHT2 / 2
|
|
1460
|
+
};
|
|
1461
|
+
}, [durationInFrames, frame, inFrame, width]);
|
|
1462
|
+
const active = useMemo6(() => {
|
|
1463
|
+
return {
|
|
1464
|
+
height: BAR_HEIGHT2,
|
|
1465
|
+
backgroundColor: "rgba(255, 255, 255, 0.25)",
|
|
1466
|
+
width: ((outFrame ?? durationInFrames - 1) - (inFrame ?? 0)) / (durationInFrames - 1) * 100 + "%",
|
|
1467
|
+
marginLeft: (inFrame ?? 0) / (durationInFrames - 1) * 100 + "%",
|
|
1468
|
+
borderRadius: BAR_HEIGHT2 / 2,
|
|
1469
|
+
position: "absolute"
|
|
1470
|
+
};
|
|
1471
|
+
}, [durationInFrames, inFrame, outFrame]);
|
|
1472
|
+
return /* @__PURE__ */ jsxs6("div", {
|
|
1473
|
+
ref: containerRef,
|
|
1474
|
+
onPointerDown,
|
|
1475
|
+
style: containerStyle,
|
|
1476
|
+
children: [
|
|
1477
|
+
/* @__PURE__ */ jsxs6("div", {
|
|
1478
|
+
style: barBackground,
|
|
1479
|
+
children: [
|
|
1480
|
+
/* @__PURE__ */ jsx8("div", {
|
|
1481
|
+
style: active
|
|
1482
|
+
}),
|
|
1483
|
+
/* @__PURE__ */ jsx8("div", {
|
|
1484
|
+
style: fillStyle
|
|
1485
|
+
})
|
|
1486
|
+
]
|
|
1487
|
+
}),
|
|
1488
|
+
/* @__PURE__ */ jsx8("div", {
|
|
1489
|
+
style: knobStyle
|
|
1490
|
+
})
|
|
1491
|
+
]
|
|
1539
1492
|
});
|
|
1540
1493
|
};
|
|
1541
1494
|
|
|
1542
|
-
// src/
|
|
1543
|
-
import {
|
|
1495
|
+
// src/PlayerTimeLabel.tsx
|
|
1496
|
+
import { useMemo as useMemo7 } from "react";
|
|
1497
|
+
import { Internals as Internals7 } from "remotion";
|
|
1544
1498
|
|
|
1545
|
-
// src/
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
type: "player"
|
|
1551
|
-
});
|
|
1552
|
-
}
|
|
1553
|
-
if (playing) {
|
|
1554
|
-
return /* @__PURE__ */ jsx6(PauseIcon, {});
|
|
1555
|
-
}
|
|
1556
|
-
return /* @__PURE__ */ jsx6(PlayIcon, {});
|
|
1499
|
+
// src/format-time.ts
|
|
1500
|
+
var formatTime = (timeInSeconds) => {
|
|
1501
|
+
const minutes = Math.floor(timeInSeconds / 60);
|
|
1502
|
+
const seconds = Math.floor(timeInSeconds - minutes * 60);
|
|
1503
|
+
return `${String(minutes)}:${String(seconds).padStart(2, "0")}`;
|
|
1557
1504
|
};
|
|
1558
1505
|
|
|
1559
|
-
// src/
|
|
1560
|
-
import {
|
|
1561
|
-
|
|
1506
|
+
// src/PlayerTimeLabel.tsx
|
|
1507
|
+
import { jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1508
|
+
var PlayerTimeLabel = ({ durationInFrames, maxTimeLabelWidth, fps }) => {
|
|
1509
|
+
const frame = Internals7.Timeline.useTimelinePosition();
|
|
1510
|
+
const timeLabel = useMemo7(() => {
|
|
1511
|
+
return {
|
|
1512
|
+
color: "white",
|
|
1513
|
+
fontFamily: "sans-serif",
|
|
1514
|
+
fontSize: 14,
|
|
1515
|
+
maxWidth: maxTimeLabelWidth === null ? undefined : maxTimeLabelWidth,
|
|
1516
|
+
overflow: "hidden",
|
|
1517
|
+
textOverflow: "ellipsis"
|
|
1518
|
+
};
|
|
1519
|
+
}, [maxTimeLabelWidth]);
|
|
1520
|
+
const isLastFrame = frame === durationInFrames - 1;
|
|
1521
|
+
const frameToDisplay = isLastFrame ? frame + 1 : frame;
|
|
1522
|
+
return /* @__PURE__ */ jsxs7("div", {
|
|
1523
|
+
style: timeLabel,
|
|
1524
|
+
children: [
|
|
1525
|
+
formatTime(frameToDisplay / fps),
|
|
1526
|
+
" / ",
|
|
1527
|
+
formatTime(durationInFrames / fps)
|
|
1528
|
+
]
|
|
1529
|
+
});
|
|
1530
|
+
};
|
|
1562
1531
|
|
|
1563
|
-
// src/
|
|
1564
|
-
import
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
var
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
volume,
|
|
1571
|
-
isVertical,
|
|
1572
|
-
onBlur,
|
|
1573
|
-
inputRef,
|
|
1574
|
-
setVolume
|
|
1532
|
+
// src/use-video-controls-resize.ts
|
|
1533
|
+
import { useMemo as useMemo8 } from "react";
|
|
1534
|
+
var X_SPACER = 10;
|
|
1535
|
+
var X_PADDING = 12;
|
|
1536
|
+
var useVideoControlsResize = ({
|
|
1537
|
+
allowFullscreen: allowFullScreen,
|
|
1538
|
+
playerWidth
|
|
1575
1539
|
}) => {
|
|
1576
|
-
const
|
|
1577
|
-
const
|
|
1578
|
-
const
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
...common,
|
|
1588
|
-
position: "absolute",
|
|
1589
|
-
transform: `rotate(-90deg) translateX(${VOLUME_SLIDER_WIDTH / 2 + ICON_SIZE / 2}px)`
|
|
1590
|
-
};
|
|
1591
|
-
}
|
|
1540
|
+
const resizeInfo = useMemo8(() => {
|
|
1541
|
+
const playPauseIconSize = ICON_SIZE;
|
|
1542
|
+
const volumeIconSize = ICON_SIZE;
|
|
1543
|
+
const _fullscreenIconSize = allowFullScreen ? fullscreenIconSize : 0;
|
|
1544
|
+
const elementsSize = volumeIconSize + playPauseIconSize + _fullscreenIconSize + X_PADDING * 2 + X_SPACER * 2;
|
|
1545
|
+
const maxTimeLabelWidth = playerWidth - elementsSize;
|
|
1546
|
+
const maxTimeLabelWidthWithoutNegativeValue = Math.max(maxTimeLabelWidth, 0);
|
|
1547
|
+
const availableTimeLabelWidthIfVolumeOpen = maxTimeLabelWidthWithoutNegativeValue - VOLUME_SLIDER_WIDTH;
|
|
1548
|
+
const computedLabelWidth = availableTimeLabelWidthIfVolumeOpen < VOLUME_SLIDER_WIDTH ? maxTimeLabelWidthWithoutNegativeValue : availableTimeLabelWidthIfVolumeOpen;
|
|
1549
|
+
const minWidthForHorizontalDisplay = computedLabelWidth + elementsSize + VOLUME_SLIDER_WIDTH;
|
|
1550
|
+
const displayVerticalVolumeSlider = playerWidth < minWidthForHorizontalDisplay;
|
|
1592
1551
|
return {
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
}, [isVertical]);
|
|
1596
|
-
const randomId = typeof React6.useId === "undefined" ? "volume-slider" : React6.useId();
|
|
1597
|
-
const [randomClass] = useState4(() => `__remotion-volume-slider-${random(randomId)}`.replace(".", ""));
|
|
1598
|
-
const onVolumeChange = useCallback3((e) => {
|
|
1599
|
-
setVolume(parseFloat(e.target.value));
|
|
1600
|
-
}, [setVolume]);
|
|
1601
|
-
const inputStyle = useMemo3(() => {
|
|
1602
|
-
const commonStyle = {
|
|
1603
|
-
WebkitAppearance: "none",
|
|
1604
|
-
backgroundColor: "rgba(255, 255, 255, 0.5)",
|
|
1605
|
-
borderRadius: BAR_HEIGHT / 2,
|
|
1606
|
-
cursor: "pointer",
|
|
1607
|
-
height: BAR_HEIGHT,
|
|
1608
|
-
width: VOLUME_SLIDER_WIDTH,
|
|
1609
|
-
backgroundImage: `linear-gradient(
|
|
1610
|
-
to right,
|
|
1611
|
-
white ${volume * 100}%, rgba(255, 255, 255, 0) ${volume * 100}%
|
|
1612
|
-
)`
|
|
1552
|
+
maxTimeLabelWidth: maxTimeLabelWidthWithoutNegativeValue === 0 ? null : maxTimeLabelWidthWithoutNegativeValue,
|
|
1553
|
+
displayVerticalVolumeSlider
|
|
1613
1554
|
};
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
bottom: ICON_SIZE + VOLUME_SLIDER_WIDTH / 2
|
|
1618
|
-
};
|
|
1619
|
-
}
|
|
1620
|
-
return commonStyle;
|
|
1621
|
-
}, [isVertical, volume]);
|
|
1622
|
-
const sliderStyle = `
|
|
1623
|
-
.${randomClass}::-webkit-slider-thumb {
|
|
1624
|
-
-webkit-appearance: none;
|
|
1625
|
-
background-color: white;
|
|
1626
|
-
border-radius: ${KNOB_SIZE / 2}px;
|
|
1627
|
-
box-shadow: 0 0 2px black;
|
|
1628
|
-
height: ${KNOB_SIZE}px;
|
|
1629
|
-
width: ${KNOB_SIZE}px;
|
|
1630
|
-
}
|
|
1555
|
+
}, [allowFullScreen, playerWidth]);
|
|
1556
|
+
return resizeInfo;
|
|
1557
|
+
};
|
|
1631
1558
|
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1559
|
+
// src/PlayerControls.tsx
|
|
1560
|
+
import { jsx as jsx9, jsxs as jsxs8, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
1561
|
+
var gradientSteps = [
|
|
1562
|
+
0,
|
|
1563
|
+
0.013,
|
|
1564
|
+
0.049,
|
|
1565
|
+
0.104,
|
|
1566
|
+
0.175,
|
|
1567
|
+
0.259,
|
|
1568
|
+
0.352,
|
|
1569
|
+
0.45,
|
|
1570
|
+
0.55,
|
|
1571
|
+
0.648,
|
|
1572
|
+
0.741,
|
|
1573
|
+
0.825,
|
|
1574
|
+
0.896,
|
|
1575
|
+
0.951,
|
|
1576
|
+
0.987
|
|
1577
|
+
];
|
|
1578
|
+
var gradientOpacities = [
|
|
1579
|
+
0,
|
|
1580
|
+
8.1,
|
|
1581
|
+
15.5,
|
|
1582
|
+
22.5,
|
|
1583
|
+
29,
|
|
1584
|
+
35.3,
|
|
1585
|
+
41.2,
|
|
1586
|
+
47.1,
|
|
1587
|
+
52.9,
|
|
1588
|
+
58.8,
|
|
1589
|
+
64.7,
|
|
1590
|
+
71,
|
|
1591
|
+
77.5,
|
|
1592
|
+
84.5,
|
|
1593
|
+
91.9
|
|
1594
|
+
];
|
|
1595
|
+
var globalGradientOpacity = 1 / 0.7;
|
|
1596
|
+
var containerStyle2 = {
|
|
1597
|
+
boxSizing: "border-box",
|
|
1598
|
+
position: "absolute",
|
|
1599
|
+
bottom: 0,
|
|
1600
|
+
width: "100%",
|
|
1601
|
+
paddingTop: 40,
|
|
1602
|
+
paddingBottom: 10,
|
|
1603
|
+
backgroundImage: `linear-gradient(to bottom,${gradientSteps.map((g, i) => {
|
|
1604
|
+
return `hsla(0, 0%, 0%, ${g}) ${gradientOpacities[i] * globalGradientOpacity}%`;
|
|
1605
|
+
}).join(", ")}, hsl(0, 0%, 0%) 100%)`,
|
|
1606
|
+
backgroundSize: "auto 145px",
|
|
1607
|
+
display: "flex",
|
|
1608
|
+
paddingRight: X_PADDING,
|
|
1609
|
+
paddingLeft: X_PADDING,
|
|
1610
|
+
flexDirection: "column",
|
|
1611
|
+
transition: "opacity 0.3s"
|
|
1664
1612
|
};
|
|
1665
|
-
var
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1613
|
+
var controlsRow = {
|
|
1614
|
+
display: "flex",
|
|
1615
|
+
flexDirection: "row",
|
|
1616
|
+
width: "100%",
|
|
1617
|
+
alignItems: "center",
|
|
1618
|
+
justifyContent: "center",
|
|
1619
|
+
userSelect: "none",
|
|
1620
|
+
WebkitUserSelect: "none"
|
|
1669
1621
|
};
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1622
|
+
var leftPartStyle = {
|
|
1623
|
+
display: "flex",
|
|
1624
|
+
flexDirection: "row",
|
|
1625
|
+
userSelect: "none",
|
|
1626
|
+
WebkitUserSelect: "none",
|
|
1627
|
+
alignItems: "center"
|
|
1628
|
+
};
|
|
1629
|
+
var xSpacer = {
|
|
1630
|
+
width: 12
|
|
1631
|
+
};
|
|
1632
|
+
var ySpacer = {
|
|
1633
|
+
height: 8
|
|
1634
|
+
};
|
|
1635
|
+
var flex1 = {
|
|
1636
|
+
flex: 1
|
|
1637
|
+
};
|
|
1638
|
+
var fullscreen = {};
|
|
1639
|
+
var Controls = ({
|
|
1640
|
+
durationInFrames,
|
|
1641
|
+
isFullscreen,
|
|
1642
|
+
fps,
|
|
1643
|
+
showVolumeControls,
|
|
1644
|
+
onFullscreenButtonClick,
|
|
1645
|
+
allowFullscreen,
|
|
1646
|
+
onExitFullscreenButtonClick,
|
|
1647
|
+
spaceKeyToPlayOrPause,
|
|
1648
|
+
onSeekEnd,
|
|
1649
|
+
onSeekStart,
|
|
1650
|
+
inFrame,
|
|
1651
|
+
outFrame,
|
|
1652
|
+
initiallyShowControls,
|
|
1653
|
+
canvasSize,
|
|
1654
|
+
renderPlayPauseButton,
|
|
1655
|
+
renderFullscreenButton,
|
|
1656
|
+
alwaysShowControls,
|
|
1657
|
+
showPlaybackRateControl,
|
|
1658
|
+
containerRef,
|
|
1659
|
+
buffering,
|
|
1660
|
+
hideControlsWhenPointerDoesntMove,
|
|
1661
|
+
onPointerDown,
|
|
1662
|
+
onDoubleClick,
|
|
1663
|
+
renderMuteButton,
|
|
1664
|
+
renderVolumeSlider,
|
|
1665
|
+
playing,
|
|
1666
|
+
toggle,
|
|
1667
|
+
renderCustomControls
|
|
1668
|
+
}) => {
|
|
1669
|
+
const playButtonRef = useRef5(null);
|
|
1670
|
+
const [supportsFullscreen, setSupportsFullscreen] = useState9(false);
|
|
1671
|
+
const hovered = useHoverState(containerRef, hideControlsWhenPointerDoesntMove);
|
|
1672
|
+
const { maxTimeLabelWidth, displayVerticalVolumeSlider } = useVideoControlsResize({
|
|
1673
|
+
allowFullscreen,
|
|
1674
|
+
playerWidth: canvasSize?.width ?? 0
|
|
1675
|
+
});
|
|
1676
|
+
const [shouldShowInitially, setInitiallyShowControls] = useState9(() => {
|
|
1677
|
+
if (typeof initiallyShowControls === "boolean") {
|
|
1678
|
+
return initiallyShowControls;
|
|
1679
|
+
}
|
|
1680
|
+
if (typeof initiallyShowControls === "number") {
|
|
1681
|
+
if (initiallyShowControls % 1 !== 0) {
|
|
1682
|
+
throw new Error("initiallyShowControls must be an integer or a boolean");
|
|
1685
1683
|
}
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1684
|
+
if (Number.isNaN(initiallyShowControls)) {
|
|
1685
|
+
throw new Error("initiallyShowControls must not be NaN");
|
|
1686
|
+
}
|
|
1687
|
+
if (!Number.isFinite(initiallyShowControls)) {
|
|
1688
|
+
throw new Error("initiallyShowControls must be finite");
|
|
1689
|
+
}
|
|
1690
|
+
if (initiallyShowControls <= 0) {
|
|
1691
|
+
throw new Error("initiallyShowControls must be a positive integer");
|
|
1692
|
+
}
|
|
1693
|
+
return initiallyShowControls;
|
|
1694
1694
|
}
|
|
1695
|
-
|
|
1696
|
-
}
|
|
1697
|
-
const
|
|
1698
|
-
|
|
1699
|
-
display: "inline-flex",
|
|
1700
|
-
background: "none",
|
|
1701
|
-
border: "none",
|
|
1702
|
-
justifyContent: "center",
|
|
1703
|
-
alignItems: "center",
|
|
1704
|
-
touchAction: "none",
|
|
1705
|
-
...displayVerticalVolumeSlider && { position: "relative" }
|
|
1706
|
-
};
|
|
1707
|
-
}, [displayVerticalVolumeSlider]);
|
|
1708
|
-
const volumeContainer = useMemo4(() => {
|
|
1695
|
+
throw new TypeError("initiallyShowControls must be a number or a boolean");
|
|
1696
|
+
});
|
|
1697
|
+
const containerCss = useMemo9(() => {
|
|
1698
|
+
const shouldShow = hovered || !playing || shouldShowInitially || alwaysShowControls;
|
|
1709
1699
|
return {
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
height: ICON_SIZE,
|
|
1713
|
-
cursor: "pointer",
|
|
1714
|
-
appearance: "none",
|
|
1715
|
-
background: "none",
|
|
1716
|
-
border: "none",
|
|
1717
|
-
padding: 0
|
|
1700
|
+
...containerStyle2,
|
|
1701
|
+
opacity: Number(shouldShow)
|
|
1718
1702
|
};
|
|
1703
|
+
}, [hovered, shouldShowInitially, playing, alwaysShowControls]);
|
|
1704
|
+
useEffect7(() => {
|
|
1705
|
+
if (playButtonRef.current && spaceKeyToPlayOrPause) {
|
|
1706
|
+
playButtonRef.current.focus({
|
|
1707
|
+
preventScroll: true
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
}, [playing, spaceKeyToPlayOrPause]);
|
|
1711
|
+
useEffect7(() => {
|
|
1712
|
+
setSupportsFullscreen((typeof document !== "undefined" && (document.fullscreenEnabled || document.webkitFullscreenEnabled)) ?? false);
|
|
1719
1713
|
}, []);
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1714
|
+
useEffect7(() => {
|
|
1715
|
+
if (shouldShowInitially === false) {
|
|
1716
|
+
return;
|
|
1717
|
+
}
|
|
1718
|
+
const time = shouldShowInitially === true ? 2000 : shouldShowInitially;
|
|
1719
|
+
const timeout = setTimeout(() => {
|
|
1720
|
+
setInitiallyShowControls(false);
|
|
1721
|
+
}, time);
|
|
1722
|
+
return () => {
|
|
1723
|
+
clearInterval(timeout);
|
|
1724
|
+
};
|
|
1725
|
+
}, [shouldShowInitially]);
|
|
1726
|
+
const playbackRates = useMemo9(() => {
|
|
1727
|
+
if (showPlaybackRateControl === true) {
|
|
1728
|
+
return [0.5, 0.8, 1, 1.2, 1.5, 1.8, 2, 2.5, 3];
|
|
1729
|
+
}
|
|
1730
|
+
if (Array.isArray(showPlaybackRateControl)) {
|
|
1731
|
+
for (const rate of showPlaybackRateControl) {
|
|
1732
|
+
if (typeof rate !== "number") {
|
|
1733
|
+
throw new Error("Every item in showPlaybackRateControl must be a number");
|
|
1734
|
+
}
|
|
1735
|
+
if (rate <= 0) {
|
|
1736
|
+
throw new Error("Every item in showPlaybackRateControl must be positive");
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
return showPlaybackRateControl;
|
|
1740
|
+
}
|
|
1741
|
+
return null;
|
|
1742
|
+
}, [showPlaybackRateControl]);
|
|
1743
|
+
const customControlsElement = renderCustomControls ? renderCustomControls() : null;
|
|
1744
|
+
const ref = useRef5(null);
|
|
1745
|
+
const flexRef = useRef5(null);
|
|
1746
|
+
const onPointerDownIfContainer = useCallback7((e) => {
|
|
1747
|
+
if (e.target === ref.current || e.target === flexRef.current) {
|
|
1748
|
+
onPointerDown?.(e);
|
|
1749
|
+
}
|
|
1750
|
+
}, [onPointerDown]);
|
|
1751
|
+
const onDoubleClickIfContainer = useCallback7((e) => {
|
|
1752
|
+
if (e.target === ref.current || e.target === flexRef.current) {
|
|
1753
|
+
onDoubleClick?.(e);
|
|
1754
|
+
}
|
|
1755
|
+
}, [onDoubleClick]);
|
|
1756
|
+
return /* @__PURE__ */ jsxs8("div", {
|
|
1757
|
+
ref,
|
|
1758
|
+
style: containerCss,
|
|
1759
|
+
onPointerDown: onPointerDownIfContainer,
|
|
1760
|
+
onDoubleClick: onDoubleClickIfContainer,
|
|
1756
1761
|
children: [
|
|
1757
|
-
|
|
1758
|
-
|
|
1762
|
+
/* @__PURE__ */ jsxs8("div", {
|
|
1763
|
+
ref: flexRef,
|
|
1764
|
+
style: controlsRow,
|
|
1765
|
+
children: [
|
|
1766
|
+
/* @__PURE__ */ jsxs8("div", {
|
|
1767
|
+
style: leftPartStyle,
|
|
1768
|
+
children: [
|
|
1769
|
+
/* @__PURE__ */ jsx9("button", {
|
|
1770
|
+
ref: playButtonRef,
|
|
1771
|
+
type: "button",
|
|
1772
|
+
style: playerButtonStyle,
|
|
1773
|
+
onClick: toggle,
|
|
1774
|
+
"aria-label": playing ? "Pause video" : "Play video",
|
|
1775
|
+
title: playing ? "Pause video" : "Play video",
|
|
1776
|
+
children: renderPlayPauseButton === null ? /* @__PURE__ */ jsx9(DefaultPlayPauseButton, {
|
|
1777
|
+
buffering,
|
|
1778
|
+
playing
|
|
1779
|
+
}) : renderPlayPauseButton({
|
|
1780
|
+
playing,
|
|
1781
|
+
isBuffering: buffering
|
|
1782
|
+
}) ?? /* @__PURE__ */ jsx9(DefaultPlayPauseButton, {
|
|
1783
|
+
buffering,
|
|
1784
|
+
playing
|
|
1785
|
+
})
|
|
1786
|
+
}),
|
|
1787
|
+
showVolumeControls ? /* @__PURE__ */ jsxs8(Fragment2, {
|
|
1788
|
+
children: [
|
|
1789
|
+
/* @__PURE__ */ jsx9("div", {
|
|
1790
|
+
style: xSpacer
|
|
1791
|
+
}),
|
|
1792
|
+
/* @__PURE__ */ jsx9(MediaVolumeSlider, {
|
|
1793
|
+
renderMuteButton,
|
|
1794
|
+
renderVolumeSlider,
|
|
1795
|
+
displayVerticalVolumeSlider
|
|
1796
|
+
})
|
|
1797
|
+
]
|
|
1798
|
+
}) : null,
|
|
1799
|
+
/* @__PURE__ */ jsx9("div", {
|
|
1800
|
+
style: xSpacer
|
|
1801
|
+
}),
|
|
1802
|
+
/* @__PURE__ */ jsx9(PlayerTimeLabel, {
|
|
1803
|
+
durationInFrames,
|
|
1804
|
+
fps,
|
|
1805
|
+
maxTimeLabelWidth
|
|
1806
|
+
}),
|
|
1807
|
+
/* @__PURE__ */ jsx9("div", {
|
|
1808
|
+
style: xSpacer
|
|
1809
|
+
})
|
|
1810
|
+
]
|
|
1811
|
+
}),
|
|
1812
|
+
/* @__PURE__ */ jsx9("div", {
|
|
1813
|
+
style: flex1
|
|
1814
|
+
}),
|
|
1815
|
+
customControlsElement,
|
|
1816
|
+
customControlsElement && playbackRates && canvasSize ? /* @__PURE__ */ jsx9("div", {
|
|
1817
|
+
style: xSpacer
|
|
1818
|
+
}) : null,
|
|
1819
|
+
playbackRates && canvasSize && /* @__PURE__ */ jsx9(PlaybackrateControl, {
|
|
1820
|
+
canvasSize,
|
|
1821
|
+
playbackRates
|
|
1822
|
+
}),
|
|
1823
|
+
playbackRates && supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx9("div", {
|
|
1824
|
+
style: xSpacer
|
|
1825
|
+
}) : null,
|
|
1826
|
+
/* @__PURE__ */ jsx9("div", {
|
|
1827
|
+
style: fullscreen,
|
|
1828
|
+
children: supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx9("button", {
|
|
1829
|
+
type: "button",
|
|
1830
|
+
"aria-label": isFullscreen ? "Exit fullscreen" : "Enter Fullscreen",
|
|
1831
|
+
title: isFullscreen ? "Exit fullscreen" : "Enter Fullscreen",
|
|
1832
|
+
style: playerButtonStyle,
|
|
1833
|
+
onClick: isFullscreen ? onExitFullscreenButtonClick : onFullscreenButtonClick,
|
|
1834
|
+
children: renderFullscreenButton === null ? /* @__PURE__ */ jsx9(FullscreenIcon, {
|
|
1835
|
+
isFullscreen
|
|
1836
|
+
}) : renderFullscreenButton({ isFullscreen })
|
|
1837
|
+
}) : null
|
|
1838
|
+
})
|
|
1839
|
+
]
|
|
1840
|
+
}),
|
|
1841
|
+
/* @__PURE__ */ jsx9("div", {
|
|
1842
|
+
style: ySpacer
|
|
1843
|
+
}),
|
|
1844
|
+
/* @__PURE__ */ jsx9(PlayerSeekBar, {
|
|
1845
|
+
onSeekEnd,
|
|
1846
|
+
onSeekStart,
|
|
1847
|
+
durationInFrames,
|
|
1848
|
+
inFrame,
|
|
1849
|
+
outFrame
|
|
1850
|
+
})
|
|
1759
1851
|
]
|
|
1760
1852
|
});
|
|
1761
1853
|
};
|
|
1762
1854
|
|
|
1763
|
-
// src/
|
|
1764
|
-
import
|
|
1765
|
-
|
|
1855
|
+
// src/timeline-sequence-observer-context.ts
|
|
1856
|
+
import React8 from "react";
|
|
1857
|
+
var TimelineSequenceObserverContext = React8.createContext(null);
|
|
1766
1858
|
|
|
1767
|
-
// src/
|
|
1768
|
-
import {
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1859
|
+
// src/use-playback.ts
|
|
1860
|
+
import { useLayoutEffect as useLayoutEffect2 } from "react";
|
|
1861
|
+
import { useContext as useContext3, useEffect as useEffect10, useRef as useRef8 } from "react";
|
|
1862
|
+
import { Internals as Internals10 } from "remotion";
|
|
1863
|
+
|
|
1864
|
+
// src/browser-mediasession.ts
|
|
1865
|
+
import { useEffect as useEffect8, useRef as useRef6 } from "react";
|
|
1866
|
+
import { Internals as Internals8 } from "remotion";
|
|
1867
|
+
var useBrowserMediaSession = ({
|
|
1868
|
+
browserMediaControlsBehavior,
|
|
1869
|
+
videoConfig,
|
|
1870
|
+
playbackRate
|
|
1871
|
+
}) => {
|
|
1872
|
+
const playing = Internals8.usePlaying();
|
|
1873
|
+
const { pause, play, emitter, getCurrentFrame, seek } = usePlayerMethods();
|
|
1874
|
+
const hasEverPlayed = useRef6(false);
|
|
1772
1875
|
useEffect8(() => {
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1876
|
+
if (playing) {
|
|
1877
|
+
hasEverPlayed.current = true;
|
|
1878
|
+
}
|
|
1879
|
+
if (!navigator.mediaSession) {
|
|
1880
|
+
return;
|
|
1881
|
+
}
|
|
1882
|
+
if (browserMediaControlsBehavior.mode === "do-nothing") {
|
|
1883
|
+
return;
|
|
1884
|
+
}
|
|
1885
|
+
if (playing) {
|
|
1886
|
+
navigator.mediaSession.playbackState = "playing";
|
|
1887
|
+
} else if (hasEverPlayed.current) {
|
|
1888
|
+
navigator.mediaSession.playbackState = "paused";
|
|
1889
|
+
}
|
|
1890
|
+
}, [browserMediaControlsBehavior.mode, playing]);
|
|
1891
|
+
useEffect8(() => {
|
|
1892
|
+
if (!navigator.mediaSession) {
|
|
1893
|
+
return;
|
|
1894
|
+
}
|
|
1895
|
+
if (browserMediaControlsBehavior.mode === "do-nothing") {
|
|
1896
|
+
return;
|
|
1897
|
+
}
|
|
1898
|
+
const onTimeUpdate = () => {
|
|
1899
|
+
if (!videoConfig) {
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
if (navigator.mediaSession) {
|
|
1903
|
+
navigator.mediaSession.setPositionState({
|
|
1904
|
+
duration: videoConfig.durationInFrames / videoConfig.fps,
|
|
1905
|
+
playbackRate,
|
|
1906
|
+
position: getCurrentFrame() / videoConfig.fps
|
|
1907
|
+
});
|
|
1776
1908
|
}
|
|
1777
1909
|
};
|
|
1778
|
-
|
|
1910
|
+
emitter.addEventListener("timeupdate", onTimeUpdate);
|
|
1779
1911
|
return () => {
|
|
1780
|
-
|
|
1781
|
-
};
|
|
1782
|
-
}, []);
|
|
1783
|
-
return { ref, isComponentVisible, setIsComponentVisible };
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
// src/PlaybackrateControl.tsx
|
|
1787
|
-
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1788
|
-
var BOTTOM = 35;
|
|
1789
|
-
var THRESHOLD = 70;
|
|
1790
|
-
var rateDiv = {
|
|
1791
|
-
height: 30,
|
|
1792
|
-
paddingRight: 15,
|
|
1793
|
-
paddingLeft: 12,
|
|
1794
|
-
display: "flex",
|
|
1795
|
-
flexDirection: "row",
|
|
1796
|
-
alignItems: "center"
|
|
1797
|
-
};
|
|
1798
|
-
var checkmarkContainer = {
|
|
1799
|
-
width: 22,
|
|
1800
|
-
display: "flex",
|
|
1801
|
-
alignItems: "center"
|
|
1802
|
-
};
|
|
1803
|
-
var checkmarkStyle = {
|
|
1804
|
-
width: 14,
|
|
1805
|
-
height: 14,
|
|
1806
|
-
color: "black"
|
|
1807
|
-
};
|
|
1808
|
-
var Checkmark = () => /* @__PURE__ */ jsx9("svg", {
|
|
1809
|
-
viewBox: "0 0 512 512",
|
|
1810
|
-
style: checkmarkStyle,
|
|
1811
|
-
children: /* @__PURE__ */ jsx9("path", {
|
|
1812
|
-
fill: "currentColor",
|
|
1813
|
-
d: "M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"
|
|
1814
|
-
})
|
|
1815
|
-
});
|
|
1816
|
-
var formatPlaybackRate = (rate) => {
|
|
1817
|
-
const str = rate.toString();
|
|
1818
|
-
return str.includes(".") ? str : str + ".0";
|
|
1819
|
-
};
|
|
1820
|
-
var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }) => {
|
|
1821
|
-
const onClick = useCallback5((e) => {
|
|
1822
|
-
e.stopPropagation();
|
|
1823
|
-
e.preventDefault();
|
|
1824
|
-
onSelect(rate);
|
|
1825
|
-
}, [onSelect, rate]);
|
|
1826
|
-
const [hovered, setHovered] = useState7(false);
|
|
1827
|
-
const onMouseEnter = useCallback5(() => {
|
|
1828
|
-
setHovered(true);
|
|
1829
|
-
}, []);
|
|
1830
|
-
const onMouseLeave = useCallback5(() => {
|
|
1831
|
-
setHovered(false);
|
|
1832
|
-
}, []);
|
|
1833
|
-
const isFocused = keyboardSelectedRate === rate;
|
|
1834
|
-
const actualStyle = useMemo5(() => {
|
|
1835
|
-
return {
|
|
1836
|
-
...rateDiv,
|
|
1837
|
-
backgroundColor: hovered || isFocused ? "#eee" : "transparent"
|
|
1912
|
+
emitter.removeEventListener("timeupdate", onTimeUpdate);
|
|
1838
1913
|
};
|
|
1839
|
-
}, [
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
|
|
1857
|
-
const { setPlaybackRate, playbackRate } = Internals8.usePlaybackRate();
|
|
1858
|
-
const [keyboardSelectedRate, setKeyboardSelectedRate] = useState7(playbackRate);
|
|
1859
|
-
useEffect9(() => {
|
|
1860
|
-
const listener = (e) => {
|
|
1861
|
-
if (e.ctrlKey || e.metaKey || e.altKey) {
|
|
1862
|
-
return;
|
|
1914
|
+
}, [
|
|
1915
|
+
browserMediaControlsBehavior.mode,
|
|
1916
|
+
emitter,
|
|
1917
|
+
getCurrentFrame,
|
|
1918
|
+
playbackRate,
|
|
1919
|
+
videoConfig
|
|
1920
|
+
]);
|
|
1921
|
+
useEffect8(() => {
|
|
1922
|
+
if (!navigator.mediaSession) {
|
|
1923
|
+
return;
|
|
1924
|
+
}
|
|
1925
|
+
if (browserMediaControlsBehavior.mode === "do-nothing") {
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
navigator.mediaSession.setActionHandler("play", () => {
|
|
1929
|
+
if (browserMediaControlsBehavior.mode === "register-media-session") {
|
|
1930
|
+
play();
|
|
1863
1931
|
}
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
return;
|
|
1869
|
-
}
|
|
1870
|
-
if (currentIndex === -1) {
|
|
1871
|
-
setKeyboardSelectedRate(playbackRates[0]);
|
|
1872
|
-
} else {
|
|
1873
|
-
setKeyboardSelectedRate(playbackRates[currentIndex - 1]);
|
|
1874
|
-
}
|
|
1875
|
-
} else if (e.key === "ArrowDown") {
|
|
1876
|
-
e.preventDefault();
|
|
1877
|
-
const currentIndex = playbackRates.findIndex((rate) => rate === keyboardSelectedRate);
|
|
1878
|
-
if (currentIndex === playbackRates.length - 1) {
|
|
1879
|
-
return;
|
|
1880
|
-
}
|
|
1881
|
-
if (currentIndex === -1) {
|
|
1882
|
-
setKeyboardSelectedRate(playbackRates[playbackRates.length - 1]);
|
|
1883
|
-
} else {
|
|
1884
|
-
setKeyboardSelectedRate(playbackRates[currentIndex + 1]);
|
|
1885
|
-
}
|
|
1886
|
-
} else if (e.key === "Enter") {
|
|
1887
|
-
e.preventDefault();
|
|
1888
|
-
setPlaybackRate(keyboardSelectedRate);
|
|
1889
|
-
setIsComponentVisible(false);
|
|
1890
|
-
} else if (e.key === "Escape") {
|
|
1891
|
-
e.preventDefault();
|
|
1892
|
-
setIsComponentVisible(false);
|
|
1893
|
-
} else if (e.key === "Tab") {
|
|
1894
|
-
setIsComponentVisible(false);
|
|
1932
|
+
});
|
|
1933
|
+
navigator.mediaSession.setActionHandler("pause", () => {
|
|
1934
|
+
if (browserMediaControlsBehavior.mode === "register-media-session") {
|
|
1935
|
+
pause();
|
|
1895
1936
|
}
|
|
1896
|
-
};
|
|
1897
|
-
|
|
1937
|
+
});
|
|
1938
|
+
navigator.mediaSession.setActionHandler("seekto", (event) => {
|
|
1939
|
+
if (browserMediaControlsBehavior.mode === "register-media-session" && event.seekTime !== undefined && videoConfig) {
|
|
1940
|
+
seek(Math.round(event.seekTime * videoConfig.fps));
|
|
1941
|
+
}
|
|
1942
|
+
});
|
|
1943
|
+
navigator.mediaSession.setActionHandler("seekbackward", () => {
|
|
1944
|
+
if (browserMediaControlsBehavior.mode === "register-media-session" && videoConfig) {
|
|
1945
|
+
seek(Math.max(0, Math.round(getCurrentFrame() - 10 * videoConfig.fps)));
|
|
1946
|
+
}
|
|
1947
|
+
});
|
|
1948
|
+
navigator.mediaSession.setActionHandler("seekforward", () => {
|
|
1949
|
+
if (browserMediaControlsBehavior.mode === "register-media-session" && videoConfig) {
|
|
1950
|
+
seek(Math.min(videoConfig.durationInFrames - 1, Math.round(getCurrentFrame() + 10 * videoConfig.fps)));
|
|
1951
|
+
}
|
|
1952
|
+
});
|
|
1953
|
+
navigator.mediaSession.setActionHandler("previoustrack", () => {
|
|
1954
|
+
if (browserMediaControlsBehavior.mode === "register-media-session") {
|
|
1955
|
+
seek(0);
|
|
1956
|
+
}
|
|
1957
|
+
});
|
|
1898
1958
|
return () => {
|
|
1899
|
-
|
|
1959
|
+
navigator.mediaSession.metadata = null;
|
|
1960
|
+
navigator.mediaSession.setActionHandler("play", null);
|
|
1961
|
+
navigator.mediaSession.setActionHandler("pause", null);
|
|
1962
|
+
navigator.mediaSession.setActionHandler("seekto", null);
|
|
1963
|
+
navigator.mediaSession.setActionHandler("seekbackward", null);
|
|
1964
|
+
navigator.mediaSession.setActionHandler("seekforward", null);
|
|
1965
|
+
navigator.mediaSession.setActionHandler("previoustrack", null);
|
|
1900
1966
|
};
|
|
1901
1967
|
}, [
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1968
|
+
browserMediaControlsBehavior.mode,
|
|
1969
|
+
getCurrentFrame,
|
|
1970
|
+
pause,
|
|
1971
|
+
play,
|
|
1972
|
+
seek,
|
|
1973
|
+
videoConfig
|
|
1906
1974
|
]);
|
|
1907
|
-
const onSelect = useCallback5((rate) => {
|
|
1908
|
-
setPlaybackRate(rate);
|
|
1909
|
-
setIsComponentVisible(false);
|
|
1910
|
-
}, [setIsComponentVisible, setPlaybackRate]);
|
|
1911
|
-
const playbackPopup = useMemo5(() => {
|
|
1912
|
-
return {
|
|
1913
|
-
position: "absolute",
|
|
1914
|
-
right: 0,
|
|
1915
|
-
width: 125,
|
|
1916
|
-
maxHeight: canvasSize.height - THRESHOLD - BOTTOM,
|
|
1917
|
-
bottom: 35,
|
|
1918
|
-
background: "#fff",
|
|
1919
|
-
borderRadius: 4,
|
|
1920
|
-
overflow: "auto",
|
|
1921
|
-
color: "black",
|
|
1922
|
-
textAlign: "left"
|
|
1923
|
-
};
|
|
1924
|
-
}, [canvasSize.height]);
|
|
1925
|
-
return /* @__PURE__ */ jsx9("div", {
|
|
1926
|
-
style: playbackPopup,
|
|
1927
|
-
children: playbackRates.map((rate) => {
|
|
1928
|
-
return /* @__PURE__ */ jsx9(PlaybackrateOption, {
|
|
1929
|
-
selectedRate: playbackRate,
|
|
1930
|
-
onSelect,
|
|
1931
|
-
rate,
|
|
1932
|
-
keyboardSelectedRate
|
|
1933
|
-
}, rate);
|
|
1934
|
-
})
|
|
1935
|
-
});
|
|
1936
|
-
};
|
|
1937
|
-
var label = {
|
|
1938
|
-
fontSize: 13,
|
|
1939
|
-
fontWeight: "bold",
|
|
1940
|
-
color: "white",
|
|
1941
|
-
border: "2px solid white",
|
|
1942
|
-
borderRadius: 20,
|
|
1943
|
-
paddingLeft: 8,
|
|
1944
|
-
paddingRight: 8,
|
|
1945
|
-
paddingTop: 2,
|
|
1946
|
-
paddingBottom: 2
|
|
1947
|
-
};
|
|
1948
|
-
var playerButtonStyle = {
|
|
1949
|
-
appearance: "none",
|
|
1950
|
-
backgroundColor: "transparent",
|
|
1951
|
-
border: "none",
|
|
1952
|
-
cursor: "pointer",
|
|
1953
|
-
paddingLeft: 0,
|
|
1954
|
-
paddingRight: 0,
|
|
1955
|
-
paddingTop: 6,
|
|
1956
|
-
paddingBottom: 6,
|
|
1957
|
-
height: 37,
|
|
1958
|
-
display: "inline-flex",
|
|
1959
|
-
marginBottom: 0,
|
|
1960
|
-
marginTop: 0,
|
|
1961
|
-
alignItems: "center"
|
|
1962
|
-
};
|
|
1963
|
-
var button = {
|
|
1964
|
-
...playerButtonStyle,
|
|
1965
|
-
position: "relative"
|
|
1966
1975
|
};
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1976
|
+
|
|
1977
|
+
// src/calculate-next-frame.ts
|
|
1978
|
+
var calculateNextFrame = ({
|
|
1979
|
+
time,
|
|
1980
|
+
currentFrame: startFrame,
|
|
1981
|
+
playbackSpeed,
|
|
1982
|
+
fps,
|
|
1983
|
+
actualLastFrame,
|
|
1984
|
+
actualFirstFrame,
|
|
1985
|
+
framesAdvanced,
|
|
1986
|
+
shouldLoop
|
|
1987
|
+
}) => {
|
|
1988
|
+
const op = playbackSpeed < 0 ? Math.ceil : Math.floor;
|
|
1989
|
+
const framesToAdvance = op(time * playbackSpeed / (1000 / fps)) - framesAdvanced;
|
|
1990
|
+
const nextFrame = framesToAdvance + startFrame;
|
|
1991
|
+
const isCurrentFrameOutside = startFrame > actualLastFrame || startFrame < actualFirstFrame;
|
|
1992
|
+
const isNextFrameOutside = nextFrame > actualLastFrame || nextFrame < actualFirstFrame;
|
|
1993
|
+
const hasEnded = !shouldLoop && isNextFrameOutside && !isCurrentFrameOutside;
|
|
1994
|
+
if (playbackSpeed > 0) {
|
|
1995
|
+
if (isNextFrameOutside) {
|
|
1996
|
+
return {
|
|
1997
|
+
nextFrame: actualFirstFrame,
|
|
1998
|
+
framesToAdvance,
|
|
1999
|
+
hasEnded
|
|
2000
|
+
};
|
|
2001
|
+
}
|
|
2002
|
+
return { nextFrame, framesToAdvance, hasEnded };
|
|
2003
|
+
}
|
|
2004
|
+
if (isNextFrameOutside) {
|
|
2005
|
+
return { nextFrame: actualLastFrame, framesToAdvance, hasEnded };
|
|
2006
|
+
}
|
|
2007
|
+
return { nextFrame, framesToAdvance, hasEnded };
|
|
1998
2008
|
};
|
|
1999
2009
|
|
|
2000
|
-
// src/
|
|
2001
|
-
import {
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
extrapolateLeft: "clamp",
|
|
2008
|
-
extrapolateRight: "clamp"
|
|
2009
|
-
}));
|
|
2010
|
-
return frame;
|
|
2010
|
+
// src/is-backgrounded.ts
|
|
2011
|
+
import { useEffect as useEffect9, useRef as useRef7 } from "react";
|
|
2012
|
+
var getIsBackgrounded = () => {
|
|
2013
|
+
if (typeof document === "undefined") {
|
|
2014
|
+
return false;
|
|
2015
|
+
}
|
|
2016
|
+
return document.visibilityState === "hidden";
|
|
2011
2017
|
};
|
|
2012
|
-
var
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2018
|
+
var useIsBackgrounded = () => {
|
|
2019
|
+
const isBackgrounded = useRef7(getIsBackgrounded());
|
|
2020
|
+
useEffect9(() => {
|
|
2021
|
+
const onVisibilityChange = () => {
|
|
2022
|
+
isBackgrounded.current = getIsBackgrounded();
|
|
2023
|
+
};
|
|
2024
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
2025
|
+
return () => {
|
|
2026
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
2027
|
+
};
|
|
2028
|
+
}, []);
|
|
2029
|
+
return isBackgrounded;
|
|
2024
2030
|
};
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2031
|
+
|
|
2032
|
+
// src/set-global-time-anchor.ts
|
|
2033
|
+
import { Internals as Internals9 } from "remotion";
|
|
2034
|
+
var setGlobalTimeAnchor = ({
|
|
2035
|
+
audioContext,
|
|
2036
|
+
audioSyncAnchor,
|
|
2037
|
+
absoluteTimeInSeconds,
|
|
2038
|
+
globalPlaybackRate,
|
|
2039
|
+
logLevel,
|
|
2040
|
+
force
|
|
2041
|
+
}) => {
|
|
2042
|
+
const newAnchor = audioContext.currentTime - absoluteTimeInSeconds / globalPlaybackRate;
|
|
2043
|
+
const shift = newAnchor - audioSyncAnchor.value;
|
|
2044
|
+
const tolerance = Internals9.getAudioSyncAnchorTolerance(audioContext);
|
|
2045
|
+
if (Math.abs(shift) < tolerance && !force) {
|
|
2046
|
+
return false;
|
|
2047
|
+
}
|
|
2048
|
+
if (Math.abs(shift) < Number.EPSILON) {
|
|
2049
|
+
return false;
|
|
2050
|
+
}
|
|
2051
|
+
Internals9.Log.verbose({ logLevel, tag: "audio-scheduling" }, "Anchor " + (force ? "forcibly " : "") + "changed from %s to %s with shift %s", audioSyncAnchor.value, newAnchor, shift);
|
|
2052
|
+
audioSyncAnchor.value = newAnchor;
|
|
2053
|
+
return true;
|
|
2030
2054
|
};
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2055
|
+
|
|
2056
|
+
// src/use-playback.ts
|
|
2057
|
+
var shouldForceAnchorChange = (newState) => {
|
|
2058
|
+
if (newState === "suspended" || newState === "running-to-suspended") {
|
|
2059
|
+
return true;
|
|
2035
2060
|
}
|
|
2036
|
-
|
|
2061
|
+
if (newState === "closed" || newState === "interrupted" || newState === "running" || newState === "suspended-to-running") {
|
|
2062
|
+
return false;
|
|
2063
|
+
}
|
|
2064
|
+
throw new Error(`Unexpected audio context state: ${newState}`);
|
|
2037
2065
|
};
|
|
2038
|
-
var
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2066
|
+
var usePlayback = ({
|
|
2067
|
+
loop,
|
|
2068
|
+
playbackRate,
|
|
2069
|
+
moveToBeginningWhenEnded,
|
|
2070
|
+
inFrame,
|
|
2071
|
+
outFrame,
|
|
2072
|
+
browserMediaControlsBehavior,
|
|
2073
|
+
getCurrentFrame,
|
|
2074
|
+
muted
|
|
2075
|
+
}) => {
|
|
2076
|
+
const config = Internals10.useUnsafeVideoConfig();
|
|
2077
|
+
const fps = config?.fps ?? null;
|
|
2078
|
+
const durationInFrames = config?.durationInFrames ?? null;
|
|
2079
|
+
const compositionId = config?.id ?? null;
|
|
2080
|
+
const frame = Internals10.Timeline.useTimelinePosition();
|
|
2081
|
+
const playing = Internals10.usePlaying();
|
|
2082
|
+
const { pause, emitter, isPlaying } = usePlayerMethods();
|
|
2083
|
+
const setFrameFromPlayback = Internals10.Timeline.useTimelineSetFrameWithoutSeek();
|
|
2084
|
+
const sharedAudioContext = useContext3(Internals10.SharedAudioContext);
|
|
2085
|
+
const { setPlayerMuted } = useContext3(Internals10.SetMediaVolumeContext);
|
|
2086
|
+
const { isBuffering, subscribeBuffering, seek } = useContext3(Internals10.SetTimelineContext);
|
|
2087
|
+
const logLevel = Internals10.useLogLevel();
|
|
2088
|
+
const isBackgroundedRef = useIsBackgrounded();
|
|
2089
|
+
const lastTimeUpdateTimestamp = useRef8(0);
|
|
2090
|
+
const playbackClockRef = useRef8(null);
|
|
2091
|
+
const previousMutedRef = useRef8(muted);
|
|
2092
|
+
const anchoredAudioContextRef = useRef8(null);
|
|
2093
|
+
useBrowserMediaSession({
|
|
2094
|
+
browserMediaControlsBehavior,
|
|
2095
|
+
playbackRate,
|
|
2096
|
+
videoConfig: config
|
|
2049
2097
|
});
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2098
|
+
useLayoutEffect2(() => {
|
|
2099
|
+
if (!sharedAudioContext) {
|
|
2100
|
+
return;
|
|
2101
|
+
}
|
|
2102
|
+
if (!sharedAudioContext.audioContext) {
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
if (fps === null) {
|
|
2106
|
+
return;
|
|
2107
|
+
}
|
|
2108
|
+
if (muted) {
|
|
2109
|
+
return;
|
|
2110
|
+
}
|
|
2111
|
+
const changed = setGlobalTimeAnchor({
|
|
2112
|
+
audioContext: sharedAudioContext.audioContext,
|
|
2113
|
+
audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
|
|
2114
|
+
absoluteTimeInSeconds: frame / fps,
|
|
2115
|
+
globalPlaybackRate: playbackRate,
|
|
2116
|
+
logLevel,
|
|
2117
|
+
force: false
|
|
2118
|
+
});
|
|
2119
|
+
if (changed) {
|
|
2120
|
+
sharedAudioContext.audioSyncAnchorEmitter.dispatch("changed");
|
|
2121
|
+
}
|
|
2122
|
+
}, [fps, frame, logLevel, playbackRate, sharedAudioContext, muted]);
|
|
2123
|
+
useLayoutEffect2(() => {
|
|
2124
|
+
const audioContext = sharedAudioContext?.audioContext;
|
|
2125
|
+
if (!audioContext) {
|
|
2053
2126
|
return;
|
|
2054
2127
|
}
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
const wasPlaying = isPlaying();
|
|
2058
|
-
pause();
|
|
2059
|
-
seek(_frame);
|
|
2060
|
-
setDragging({
|
|
2061
|
-
dragging: true,
|
|
2062
|
-
wasPlaying
|
|
2063
|
-
});
|
|
2064
|
-
onSeekStart();
|
|
2065
|
-
}, [durationInFrames, width, isPlaying, pause, seek, onSeekStart]);
|
|
2066
|
-
const onPointerMove = useCallback6((e) => {
|
|
2067
|
-
if (!size) {
|
|
2068
|
-
throw new Error("Player has no size");
|
|
2128
|
+
if (fps === null) {
|
|
2129
|
+
return;
|
|
2069
2130
|
}
|
|
2070
|
-
if (
|
|
2131
|
+
if (muted) {
|
|
2071
2132
|
return;
|
|
2072
2133
|
}
|
|
2073
|
-
const
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2134
|
+
const callback = () => {
|
|
2135
|
+
const newState = sharedAudioContext?.getAudioContextState();
|
|
2136
|
+
if (newState && shouldForceAnchorChange(newState)) {
|
|
2137
|
+
const changed = setGlobalTimeAnchor({
|
|
2138
|
+
audioContext,
|
|
2139
|
+
audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
|
|
2140
|
+
absoluteTimeInSeconds: getCurrentFrame() / fps,
|
|
2141
|
+
globalPlaybackRate: playbackRate,
|
|
2142
|
+
logLevel,
|
|
2143
|
+
force: true
|
|
2144
|
+
});
|
|
2145
|
+
if (changed) {
|
|
2146
|
+
sharedAudioContext.audioSyncAnchorEmitter.dispatch("changed");
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
};
|
|
2150
|
+
audioContext?.addEventListener("statechange", callback);
|
|
2151
|
+
return () => {
|
|
2152
|
+
audioContext?.removeEventListener("statechange", callback);
|
|
2153
|
+
};
|
|
2154
|
+
}, [fps, getCurrentFrame, logLevel, muted, playbackRate, sharedAudioContext]);
|
|
2155
|
+
useEffect10(() => {
|
|
2156
|
+
const wasMuted = previousMutedRef.current;
|
|
2157
|
+
previousMutedRef.current = muted;
|
|
2158
|
+
if (fps === null || durationInFrames === null || compositionId === null) {
|
|
2159
|
+
playbackClockRef.current = null;
|
|
2082
2160
|
return;
|
|
2083
2161
|
}
|
|
2084
|
-
if (
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2162
|
+
if (!playing) {
|
|
2163
|
+
playbackClockRef.current = null;
|
|
2164
|
+
sharedAudioContext?.suspend?.();
|
|
2165
|
+
return;
|
|
2088
2166
|
}
|
|
2089
|
-
|
|
2090
|
-
|
|
2167
|
+
if (muted) {
|
|
2168
|
+
sharedAudioContext?.suspend?.();
|
|
2169
|
+
}
|
|
2170
|
+
const previousClock = playbackClockRef.current;
|
|
2171
|
+
const shouldRestartClock = previousClock === null || previousClock.compositionId !== compositionId || previousClock.fps !== fps || previousClock.playbackRate !== playbackRate;
|
|
2172
|
+
const clock = shouldRestartClock ? {
|
|
2173
|
+
compositionId,
|
|
2174
|
+
startedTime: performance.now(),
|
|
2175
|
+
framesAdvanced: 0,
|
|
2176
|
+
fps,
|
|
2177
|
+
playbackRate
|
|
2178
|
+
} : previousClock;
|
|
2179
|
+
playbackClockRef.current = clock;
|
|
2180
|
+
if (sharedAudioContext?._experimentalKeepAudioContextAlive && sharedAudioContext.audioContext && !muted) {
|
|
2181
|
+
const didUnmute = wasMuted && !muted;
|
|
2182
|
+
const didReplaceAudioContext = anchoredAudioContextRef.current !== sharedAudioContext.audioContext;
|
|
2183
|
+
const shouldRescheduleAudio = shouldRestartClock || didUnmute || didReplaceAudioContext;
|
|
2184
|
+
const changed = setGlobalTimeAnchor({
|
|
2185
|
+
audioContext: sharedAudioContext.audioContext,
|
|
2186
|
+
audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
|
|
2187
|
+
absoluteTimeInSeconds: getCurrentFrame() / fps,
|
|
2188
|
+
globalPlaybackRate: playbackRate,
|
|
2189
|
+
logLevel,
|
|
2190
|
+
force: shouldRescheduleAudio
|
|
2191
|
+
});
|
|
2192
|
+
anchoredAudioContextRef.current = sharedAudioContext.audioContext;
|
|
2193
|
+
if (changed || shouldRescheduleAudio) {
|
|
2194
|
+
sharedAudioContext.audioSyncAnchorEmitter.dispatch("changed");
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
let hasBeenStopped = false;
|
|
2198
|
+
let audioContextFailed = false;
|
|
2199
|
+
let reqAnimFrameCall = null;
|
|
2200
|
+
let playbackFrame = getCurrentFrame();
|
|
2201
|
+
let lastSeekRevision = seek?.revision.current ?? null;
|
|
2202
|
+
const cancelQueuedFrame = () => {
|
|
2203
|
+
if (reqAnimFrameCall !== null) {
|
|
2204
|
+
if (reqAnimFrameCall.type === "raf") {
|
|
2205
|
+
cancelAnimationFrame(reqAnimFrameCall.id);
|
|
2206
|
+
} else {
|
|
2207
|
+
clearTimeout(reqAnimFrameCall.id);
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
};
|
|
2211
|
+
const stop = () => {
|
|
2212
|
+
hasBeenStopped = true;
|
|
2213
|
+
cancelQueuedFrame();
|
|
2214
|
+
};
|
|
2215
|
+
const callback = () => {
|
|
2216
|
+
if (hasBeenStopped) {
|
|
2217
|
+
return;
|
|
2218
|
+
}
|
|
2219
|
+
if (!isPlaying()) {
|
|
2220
|
+
sharedAudioContext?.suspend?.();
|
|
2221
|
+
return;
|
|
2222
|
+
}
|
|
2223
|
+
if (!muted && !audioContextFailed && !isBuffering()) {
|
|
2224
|
+
sharedAudioContext?.resume?.();
|
|
2225
|
+
}
|
|
2226
|
+
const time = performance.now() - clock.startedTime;
|
|
2227
|
+
const actualLastFrame = outFrame ?? durationInFrames - 1;
|
|
2228
|
+
const actualFirstFrame = inFrame ?? 0;
|
|
2229
|
+
const seekRevision = seek?.revision.current ?? null;
|
|
2230
|
+
if (seekRevision !== lastSeekRevision) {
|
|
2231
|
+
playbackFrame = getCurrentFrame();
|
|
2232
|
+
lastSeekRevision = seekRevision;
|
|
2233
|
+
}
|
|
2234
|
+
const currentFrame = playbackFrame;
|
|
2235
|
+
const { nextFrame, framesToAdvance, hasEnded } = calculateNextFrame({
|
|
2236
|
+
time,
|
|
2237
|
+
currentFrame,
|
|
2238
|
+
playbackSpeed: playbackRate,
|
|
2239
|
+
fps,
|
|
2240
|
+
actualFirstFrame,
|
|
2241
|
+
actualLastFrame,
|
|
2242
|
+
framesAdvanced: clock.framesAdvanced,
|
|
2243
|
+
shouldLoop: loop
|
|
2244
|
+
});
|
|
2245
|
+
clock.framesAdvanced += framesToAdvance;
|
|
2246
|
+
const frameToDisplay = hasEnded && !moveToBeginningWhenEnded ? playbackRate > 0 ? actualLastFrame : actualFirstFrame : nextFrame;
|
|
2247
|
+
if (frameToDisplay !== currentFrame && !isBuffering()) {
|
|
2248
|
+
playbackFrame = frameToDisplay;
|
|
2249
|
+
setFrameFromPlayback((c) => ({ ...c, [compositionId]: frameToDisplay }));
|
|
2250
|
+
}
|
|
2251
|
+
if (hasEnded) {
|
|
2252
|
+
stop();
|
|
2253
|
+
pause();
|
|
2254
|
+
emitter.dispatchEnded();
|
|
2255
|
+
return;
|
|
2256
|
+
}
|
|
2257
|
+
queueNextFrame();
|
|
2258
|
+
};
|
|
2259
|
+
const queueNextFrame = () => {
|
|
2260
|
+
if (hasBeenStopped) {
|
|
2261
|
+
return;
|
|
2262
|
+
}
|
|
2263
|
+
const getIsResumingAudioContext = audioContextFailed ? null : sharedAudioContext?.getIsResumingAudioContext?.() ?? null;
|
|
2264
|
+
if (getIsResumingAudioContext !== null && !muted) {
|
|
2265
|
+
getIsResumingAudioContext.then((result) => {
|
|
2266
|
+
if (hasBeenStopped) {
|
|
2267
|
+
return;
|
|
2268
|
+
}
|
|
2269
|
+
if (result === "failed") {
|
|
2270
|
+
audioContextFailed = true;
|
|
2271
|
+
sharedAudioContext?.suspend();
|
|
2272
|
+
setPlayerMuted(true);
|
|
2273
|
+
}
|
|
2274
|
+
clock.startedTime = performance.now();
|
|
2275
|
+
clock.framesAdvanced = 0;
|
|
2276
|
+
queueNextFrame();
|
|
2277
|
+
});
|
|
2278
|
+
return;
|
|
2279
|
+
}
|
|
2280
|
+
if (isBuffering()) {
|
|
2281
|
+
if (!muted && !audioContextFailed) {
|
|
2282
|
+
sharedAudioContext?.suspend?.();
|
|
2283
|
+
}
|
|
2284
|
+
const unsubscribe = subscribeBuffering((state) => {
|
|
2285
|
+
if (state.buffering) {
|
|
2286
|
+
return;
|
|
2287
|
+
}
|
|
2288
|
+
unsubscribe();
|
|
2289
|
+
if (!muted && !audioContextFailed && sharedAudioContext?._experimentalKeepAudioContextAlive) {
|
|
2290
|
+
sharedAudioContext.resume();
|
|
2291
|
+
}
|
|
2292
|
+
clock.startedTime = performance.now();
|
|
2293
|
+
clock.framesAdvanced = 0;
|
|
2294
|
+
queueNextFrame();
|
|
2295
|
+
});
|
|
2296
|
+
return;
|
|
2297
|
+
}
|
|
2298
|
+
if (isBackgroundedRef.current) {
|
|
2299
|
+
reqAnimFrameCall = {
|
|
2300
|
+
type: "timeout",
|
|
2301
|
+
id: setTimeout(callback, 1000 / fps)
|
|
2302
|
+
};
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
reqAnimFrameCall = { type: "raf", id: requestAnimationFrame(callback) };
|
|
2306
|
+
};
|
|
2307
|
+
queueNextFrame();
|
|
2308
|
+
const onVisibilityChange = () => {
|
|
2309
|
+
if (document.visibilityState === "visible") {
|
|
2310
|
+
return;
|
|
2311
|
+
}
|
|
2312
|
+
cancelQueuedFrame();
|
|
2313
|
+
callback();
|
|
2314
|
+
};
|
|
2315
|
+
window.addEventListener("visibilitychange", onVisibilityChange);
|
|
2316
|
+
return () => {
|
|
2317
|
+
window.removeEventListener("visibilitychange", onVisibilityChange);
|
|
2318
|
+
stop();
|
|
2319
|
+
};
|
|
2320
|
+
}, [
|
|
2321
|
+
compositionId,
|
|
2322
|
+
durationInFrames,
|
|
2323
|
+
fps,
|
|
2324
|
+
loop,
|
|
2325
|
+
pause,
|
|
2326
|
+
playing,
|
|
2327
|
+
setFrameFromPlayback,
|
|
2328
|
+
emitter,
|
|
2329
|
+
playbackRate,
|
|
2330
|
+
inFrame,
|
|
2331
|
+
outFrame,
|
|
2332
|
+
moveToBeginningWhenEnded,
|
|
2333
|
+
isBackgroundedRef,
|
|
2334
|
+
getCurrentFrame,
|
|
2335
|
+
isBuffering,
|
|
2336
|
+
isPlaying,
|
|
2337
|
+
sharedAudioContext,
|
|
2338
|
+
setPlayerMuted,
|
|
2339
|
+
subscribeBuffering,
|
|
2340
|
+
seek,
|
|
2341
|
+
logLevel,
|
|
2342
|
+
muted
|
|
2343
|
+
]);
|
|
2091
2344
|
useEffect10(() => {
|
|
2092
|
-
|
|
2345
|
+
const now = performance.now();
|
|
2346
|
+
const timeSinceLastUpdate = now - lastTimeUpdateTimestamp.current;
|
|
2347
|
+
if (timeSinceLastUpdate >= 250) {
|
|
2348
|
+
emitter.dispatchTimeUpdate({ frame });
|
|
2349
|
+
lastTimeUpdateTimestamp.current = now;
|
|
2093
2350
|
return;
|
|
2094
2351
|
}
|
|
2095
|
-
const
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
return {
|
|
2105
|
-
height: KNOB_SIZE2,
|
|
2106
|
-
width: KNOB_SIZE2,
|
|
2107
|
-
borderRadius: KNOB_SIZE2 / 2,
|
|
2108
|
-
position: "absolute",
|
|
2109
|
-
top: VERTICAL_PADDING - KNOB_SIZE2 / 2 + 5 / 2,
|
|
2110
|
-
backgroundColor: "white",
|
|
2111
|
-
left: Math.max(0, frame / Math.max(1, durationInFrames - 1) * width - KNOB_SIZE2 / 2),
|
|
2112
|
-
boxShadow: "0 0 2px black",
|
|
2113
|
-
opacity: Number(barHovered || dragging.dragging)
|
|
2114
|
-
};
|
|
2115
|
-
}, [barHovered, dragging.dragging, durationInFrames, frame, width]);
|
|
2116
|
-
const fillStyle = useMemo6(() => {
|
|
2117
|
-
return {
|
|
2118
|
-
height: BAR_HEIGHT2,
|
|
2119
|
-
backgroundColor: "rgba(255, 255, 255, 1)",
|
|
2120
|
-
width: (frame - (inFrame ?? 0)) / (durationInFrames - 1) * width,
|
|
2121
|
-
marginLeft: (inFrame ?? 0) / (durationInFrames - 1) * width,
|
|
2122
|
-
borderRadius: BAR_HEIGHT2 / 2
|
|
2123
|
-
};
|
|
2124
|
-
}, [durationInFrames, frame, inFrame, width]);
|
|
2125
|
-
const active = useMemo6(() => {
|
|
2126
|
-
return {
|
|
2127
|
-
height: BAR_HEIGHT2,
|
|
2128
|
-
backgroundColor: "rgba(255, 255, 255, 0.25)",
|
|
2129
|
-
width: ((outFrame ?? durationInFrames - 1) - (inFrame ?? 0)) / (durationInFrames - 1) * 100 + "%",
|
|
2130
|
-
marginLeft: (inFrame ?? 0) / (durationInFrames - 1) * 100 + "%",
|
|
2131
|
-
borderRadius: BAR_HEIGHT2 / 2,
|
|
2132
|
-
position: "absolute"
|
|
2133
|
-
};
|
|
2134
|
-
}, [durationInFrames, inFrame, outFrame]);
|
|
2135
|
-
return /* @__PURE__ */ jsxs6("div", {
|
|
2136
|
-
ref: containerRef,
|
|
2137
|
-
onPointerDown,
|
|
2138
|
-
style: containerStyle,
|
|
2139
|
-
children: [
|
|
2140
|
-
/* @__PURE__ */ jsxs6("div", {
|
|
2141
|
-
style: barBackground,
|
|
2142
|
-
children: [
|
|
2143
|
-
/* @__PURE__ */ jsx10("div", {
|
|
2144
|
-
style: active
|
|
2145
|
-
}),
|
|
2146
|
-
/* @__PURE__ */ jsx10("div", {
|
|
2147
|
-
style: fillStyle
|
|
2148
|
-
})
|
|
2149
|
-
]
|
|
2150
|
-
}),
|
|
2151
|
-
/* @__PURE__ */ jsx10("div", {
|
|
2152
|
-
style: knobStyle
|
|
2153
|
-
})
|
|
2154
|
-
]
|
|
2155
|
-
});
|
|
2352
|
+
const timeoutId = setTimeout(() => {
|
|
2353
|
+
emitter.dispatchTimeUpdate({ frame });
|
|
2354
|
+
lastTimeUpdateTimestamp.current = performance.now();
|
|
2355
|
+
}, 250 - timeSinceLastUpdate);
|
|
2356
|
+
return () => clearTimeout(timeoutId);
|
|
2357
|
+
}, [emitter, frame]);
|
|
2358
|
+
useEffect10(() => {
|
|
2359
|
+
emitter.dispatchFrameUpdate({ frame });
|
|
2360
|
+
}, [emitter, frame]);
|
|
2156
2361
|
};
|
|
2157
2362
|
|
|
2158
|
-
// src/
|
|
2159
|
-
import {
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2363
|
+
// src/Player.tsx
|
|
2364
|
+
import React13, {
|
|
2365
|
+
forwardRef as forwardRef2,
|
|
2366
|
+
useCallback as useCallback12,
|
|
2367
|
+
useEffect as useEffect13,
|
|
2368
|
+
useImperativeHandle as useImperativeHandle2,
|
|
2369
|
+
useLayoutEffect as useLayoutEffect3,
|
|
2370
|
+
useMemo as useMemo14,
|
|
2371
|
+
useRef as useRef12,
|
|
2372
|
+
useState as useState12
|
|
2373
|
+
} from "react";
|
|
2374
|
+
import { Composition, Internals as Internals15 } from "remotion";
|
|
2375
|
+
import { NoReactInternals as NoReactInternals2 } from "remotion/no-react";
|
|
2168
2376
|
|
|
2169
|
-
// src/
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
const frame = Internals10.Timeline.useTimelinePosition();
|
|
2173
|
-
const timeLabel = useMemo7(() => {
|
|
2174
|
-
return {
|
|
2175
|
-
color: "white",
|
|
2176
|
-
fontFamily: "sans-serif",
|
|
2177
|
-
fontSize: 14,
|
|
2178
|
-
maxWidth: maxTimeLabelWidth === null ? undefined : maxTimeLabelWidth,
|
|
2179
|
-
overflow: "hidden",
|
|
2180
|
-
textOverflow: "ellipsis"
|
|
2181
|
-
};
|
|
2182
|
-
}, [maxTimeLabelWidth]);
|
|
2183
|
-
const isLastFrame = frame === durationInFrames - 1;
|
|
2184
|
-
const frameToDisplay = isLastFrame ? frame + 1 : frame;
|
|
2185
|
-
return /* @__PURE__ */ jsxs7("div", {
|
|
2186
|
-
style: timeLabel,
|
|
2187
|
-
children: [
|
|
2188
|
-
formatTime(frameToDisplay / fps),
|
|
2189
|
-
" / ",
|
|
2190
|
-
formatTime(durationInFrames / fps)
|
|
2191
|
-
]
|
|
2192
|
-
});
|
|
2377
|
+
// src/player-css-classname.ts
|
|
2378
|
+
var playerCssClassname = (override) => {
|
|
2379
|
+
return override ?? "__remotion-player";
|
|
2193
2380
|
};
|
|
2194
2381
|
|
|
2195
|
-
// src/
|
|
2196
|
-
import {
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
const maxTimeLabelWidth = playerWidth - elementsSize;
|
|
2209
|
-
const maxTimeLabelWidthWithoutNegativeValue = Math.max(maxTimeLabelWidth, 0);
|
|
2210
|
-
const availableTimeLabelWidthIfVolumeOpen = maxTimeLabelWidthWithoutNegativeValue - VOLUME_SLIDER_WIDTH;
|
|
2211
|
-
const computedLabelWidth = availableTimeLabelWidthIfVolumeOpen < VOLUME_SLIDER_WIDTH ? maxTimeLabelWidthWithoutNegativeValue : availableTimeLabelWidthIfVolumeOpen;
|
|
2212
|
-
const minWidthForHorizontalDisplay = computedLabelWidth + elementsSize + VOLUME_SLIDER_WIDTH;
|
|
2213
|
-
const displayVerticalVolumeSlider = playerWidth < minWidthForHorizontalDisplay;
|
|
2214
|
-
return {
|
|
2215
|
-
maxTimeLabelWidth: maxTimeLabelWidthWithoutNegativeValue === 0 ? null : maxTimeLabelWidthWithoutNegativeValue,
|
|
2216
|
-
displayVerticalVolumeSlider
|
|
2217
|
-
};
|
|
2218
|
-
}, [allowFullScreen, playerWidth]);
|
|
2219
|
-
return resizeInfo;
|
|
2220
|
-
};
|
|
2382
|
+
// src/PlayerUI.tsx
|
|
2383
|
+
import React11, {
|
|
2384
|
+
Suspense,
|
|
2385
|
+
forwardRef,
|
|
2386
|
+
useCallback as useCallback10,
|
|
2387
|
+
useContext as useContext4,
|
|
2388
|
+
useEffect as useEffect12,
|
|
2389
|
+
useImperativeHandle,
|
|
2390
|
+
useMemo as useMemo12,
|
|
2391
|
+
useRef as useRef10,
|
|
2392
|
+
useState as useState10
|
|
2393
|
+
} from "react";
|
|
2394
|
+
import { Internals as Internals11 } from "remotion";
|
|
2221
2395
|
|
|
2222
|
-
// src/
|
|
2223
|
-
import
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
0.013,
|
|
2227
|
-
0.049,
|
|
2228
|
-
0.104,
|
|
2229
|
-
0.175,
|
|
2230
|
-
0.259,
|
|
2231
|
-
0.352,
|
|
2232
|
-
0.45,
|
|
2233
|
-
0.55,
|
|
2234
|
-
0.648,
|
|
2235
|
-
0.741,
|
|
2236
|
-
0.825,
|
|
2237
|
-
0.896,
|
|
2238
|
-
0.951,
|
|
2239
|
-
0.987
|
|
2240
|
-
];
|
|
2241
|
-
var gradientOpacities = [
|
|
2242
|
-
0,
|
|
2243
|
-
8.1,
|
|
2244
|
-
15.5,
|
|
2245
|
-
22.5,
|
|
2246
|
-
29,
|
|
2247
|
-
35.3,
|
|
2248
|
-
41.2,
|
|
2249
|
-
47.1,
|
|
2250
|
-
52.9,
|
|
2251
|
-
58.8,
|
|
2252
|
-
64.7,
|
|
2253
|
-
71,
|
|
2254
|
-
77.5,
|
|
2255
|
-
84.5,
|
|
2256
|
-
91.9
|
|
2257
|
-
];
|
|
2258
|
-
var globalGradientOpacity = 1 / 0.7;
|
|
2259
|
-
var containerStyle2 = {
|
|
2260
|
-
boxSizing: "border-box",
|
|
2261
|
-
position: "absolute",
|
|
2262
|
-
bottom: 0,
|
|
2263
|
-
width: "100%",
|
|
2264
|
-
paddingTop: 40,
|
|
2265
|
-
paddingBottom: 10,
|
|
2266
|
-
backgroundImage: `linear-gradient(to bottom,${gradientSteps.map((g, i) => {
|
|
2267
|
-
return `hsla(0, 0%, 0%, ${g}) ${gradientOpacities[i] * globalGradientOpacity}%`;
|
|
2268
|
-
}).join(", ")}, hsl(0, 0%, 0%) 100%)`,
|
|
2269
|
-
backgroundSize: "auto 145px",
|
|
2270
|
-
display: "flex",
|
|
2271
|
-
paddingRight: X_PADDING,
|
|
2272
|
-
paddingLeft: X_PADDING,
|
|
2273
|
-
flexDirection: "column",
|
|
2274
|
-
transition: "opacity 0.3s"
|
|
2275
|
-
};
|
|
2276
|
-
var controlsRow = {
|
|
2396
|
+
// src/error-boundary.tsx
|
|
2397
|
+
import React9 from "react";
|
|
2398
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
2399
|
+
var errorStyle = {
|
|
2277
2400
|
display: "flex",
|
|
2278
|
-
flexDirection: "row",
|
|
2279
|
-
width: "100%",
|
|
2280
|
-
alignItems: "center",
|
|
2281
2401
|
justifyContent: "center",
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
display: "flex",
|
|
2287
|
-
flexDirection: "row",
|
|
2288
|
-
userSelect: "none",
|
|
2289
|
-
WebkitUserSelect: "none",
|
|
2290
|
-
alignItems: "center"
|
|
2291
|
-
};
|
|
2292
|
-
var xSpacer = {
|
|
2293
|
-
width: 12
|
|
2402
|
+
alignItems: "center",
|
|
2403
|
+
flex: 1,
|
|
2404
|
+
height: "100%",
|
|
2405
|
+
width: "100%"
|
|
2294
2406
|
};
|
|
2295
|
-
|
|
2296
|
-
|
|
2407
|
+
|
|
2408
|
+
class ErrorBoundary extends React9.Component {
|
|
2409
|
+
state = { hasError: null };
|
|
2410
|
+
static getDerivedStateFromError(error) {
|
|
2411
|
+
return { hasError: error };
|
|
2412
|
+
}
|
|
2413
|
+
componentDidCatch(error) {
|
|
2414
|
+
this.props.onError(error);
|
|
2415
|
+
}
|
|
2416
|
+
render() {
|
|
2417
|
+
if (this.state.hasError) {
|
|
2418
|
+
return /* @__PURE__ */ jsx10("div", {
|
|
2419
|
+
style: errorStyle,
|
|
2420
|
+
children: this.props.errorFallback({
|
|
2421
|
+
error: this.state.hasError
|
|
2422
|
+
})
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
return this.props.children;
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
// src/license-blacklist.tsx
|
|
2430
|
+
import React10, { useEffect as useEffect11 } from "react";
|
|
2431
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
2432
|
+
var getHashOfDomain = async () => {
|
|
2433
|
+
if (typeof window === "undefined") {
|
|
2434
|
+
return null;
|
|
2435
|
+
}
|
|
2436
|
+
if (typeof window.crypto === "undefined") {
|
|
2437
|
+
return null;
|
|
2438
|
+
}
|
|
2439
|
+
if (typeof window.crypto.subtle === "undefined") {
|
|
2440
|
+
return null;
|
|
2441
|
+
}
|
|
2442
|
+
try {
|
|
2443
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(window.location.hostname));
|
|
2444
|
+
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
2445
|
+
} catch {
|
|
2446
|
+
return null;
|
|
2447
|
+
}
|
|
2297
2448
|
};
|
|
2298
|
-
var
|
|
2299
|
-
|
|
2449
|
+
var style = {
|
|
2450
|
+
backgroundColor: "red",
|
|
2451
|
+
position: "absolute",
|
|
2452
|
+
padding: 12,
|
|
2453
|
+
fontFamily: "Arial"
|
|
2300
2454
|
};
|
|
2301
|
-
var
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
onSeekStart,
|
|
2313
|
-
inFrame,
|
|
2314
|
-
outFrame,
|
|
2315
|
-
initiallyShowControls,
|
|
2316
|
-
canvasSize,
|
|
2317
|
-
renderPlayPauseButton,
|
|
2318
|
-
renderFullscreenButton,
|
|
2319
|
-
alwaysShowControls,
|
|
2320
|
-
showPlaybackRateControl,
|
|
2321
|
-
containerRef,
|
|
2322
|
-
buffering,
|
|
2323
|
-
hideControlsWhenPointerDoesntMove,
|
|
2324
|
-
onPointerDown,
|
|
2325
|
-
onDoubleClick,
|
|
2326
|
-
renderMuteButton,
|
|
2327
|
-
renderVolumeSlider,
|
|
2328
|
-
playing,
|
|
2329
|
-
toggle,
|
|
2330
|
-
renderCustomControls
|
|
2331
|
-
}) => {
|
|
2332
|
-
const playButtonRef = useRef8(null);
|
|
2333
|
-
const [supportsFullscreen, setSupportsFullscreen] = useState9(false);
|
|
2334
|
-
const hovered = useHoverState(containerRef, hideControlsWhenPointerDoesntMove);
|
|
2335
|
-
const { maxTimeLabelWidth, displayVerticalVolumeSlider } = useVideoControlsResize({
|
|
2336
|
-
allowFullscreen,
|
|
2337
|
-
playerWidth: canvasSize?.width ?? 0
|
|
2338
|
-
});
|
|
2339
|
-
const [shouldShowInitially, setInitiallyShowControls] = useState9(() => {
|
|
2340
|
-
if (typeof initiallyShowControls === "boolean") {
|
|
2341
|
-
return initiallyShowControls;
|
|
2342
|
-
}
|
|
2343
|
-
if (typeof initiallyShowControls === "number") {
|
|
2344
|
-
if (initiallyShowControls % 1 !== 0) {
|
|
2345
|
-
throw new Error("initiallyShowControls must be an integer or a boolean");
|
|
2346
|
-
}
|
|
2347
|
-
if (Number.isNaN(initiallyShowControls)) {
|
|
2348
|
-
throw new Error("initiallyShowControls must not be NaN");
|
|
2349
|
-
}
|
|
2350
|
-
if (!Number.isFinite(initiallyShowControls)) {
|
|
2351
|
-
throw new Error("initiallyShowControls must be finite");
|
|
2352
|
-
}
|
|
2353
|
-
if (initiallyShowControls <= 0) {
|
|
2354
|
-
throw new Error("initiallyShowControls must be a positive integer");
|
|
2355
|
-
}
|
|
2356
|
-
return initiallyShowControls;
|
|
2357
|
-
}
|
|
2358
|
-
throw new TypeError("initiallyShowControls must be a number or a boolean");
|
|
2359
|
-
});
|
|
2360
|
-
const containerCss = useMemo9(() => {
|
|
2361
|
-
const shouldShow = hovered || !playing || shouldShowInitially || alwaysShowControls;
|
|
2362
|
-
return {
|
|
2363
|
-
...containerStyle2,
|
|
2364
|
-
opacity: Number(shouldShow)
|
|
2365
|
-
};
|
|
2366
|
-
}, [hovered, shouldShowInitially, playing, alwaysShowControls]);
|
|
2455
|
+
var DOMAIN_BLACKLIST = [
|
|
2456
|
+
"28d262b44cc61fa750f1686b16ad0604dabfe193fbc263eec05c89b7ad4c2cd6",
|
|
2457
|
+
"4db1b0a94be33165dfefcb3ba03d04c7a2666dd27c496d3dc9fa41858e94925e",
|
|
2458
|
+
"fbc48530bbf245da790f63675e84e06bab38c3b114fab07eb350025119922bdc",
|
|
2459
|
+
"7baf10a8932757b1b3a22b3fce10a048747ac2f8eaf638603487e3705b07eb83",
|
|
2460
|
+
"8a6c21a598d8c667272b5207c051b85997bf5b45d5fb712378be3f27cd72c6a6",
|
|
2461
|
+
"a2f7aaac9c50a9255e7fc376110c4e0bfe153722dc66ed3c5d3bf2a135f65518"
|
|
2462
|
+
];
|
|
2463
|
+
var ran = false;
|
|
2464
|
+
var RenderWarningIfBlacklist = () => {
|
|
2465
|
+
const [unlicensed, setUnlicensed] = React10.useState(false);
|
|
2367
2466
|
useEffect11(() => {
|
|
2368
|
-
if (
|
|
2369
|
-
|
|
2370
|
-
preventScroll: true
|
|
2371
|
-
});
|
|
2467
|
+
if (ran) {
|
|
2468
|
+
return;
|
|
2372
2469
|
}
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2470
|
+
ran = true;
|
|
2471
|
+
getHashOfDomain().then((hash) => {
|
|
2472
|
+
if (hash && DOMAIN_BLACKLIST.includes(hash)) {
|
|
2473
|
+
setUnlicensed(true);
|
|
2474
|
+
}
|
|
2475
|
+
}).catch(() => {});
|
|
2376
2476
|
}, []);
|
|
2377
2477
|
useEffect11(() => {
|
|
2378
|
-
if (
|
|
2478
|
+
if (!unlicensed) {
|
|
2379
2479
|
return;
|
|
2380
2480
|
}
|
|
2381
|
-
const
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2481
|
+
const ensureBanner = () => {
|
|
2482
|
+
const banner = document.querySelector(".warning-banner");
|
|
2483
|
+
if (!banner) {
|
|
2484
|
+
const div = document.createElement("div");
|
|
2485
|
+
div.className = "warning-banner";
|
|
2486
|
+
Object.assign(div.style, style, {
|
|
2487
|
+
zIndex: "9999",
|
|
2488
|
+
cssText: `${style.cssText} !important;`
|
|
2489
|
+
});
|
|
2490
|
+
div.innerHTML = `
|
|
2491
|
+
<a href="https://github.com/remotion-dev/remotion/pull/4589" style="color: white;">
|
|
2492
|
+
Remotion Unlicensed – Contact hi@remotion.dev
|
|
2493
|
+
</a>
|
|
2494
|
+
`;
|
|
2495
|
+
document.body.appendChild(div);
|
|
2496
|
+
}
|
|
2497
|
+
};
|
|
2498
|
+
const observer = new MutationObserver(() => ensureBanner());
|
|
2499
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
2385
2500
|
return () => {
|
|
2386
|
-
|
|
2501
|
+
observer.disconnect();
|
|
2387
2502
|
};
|
|
2388
|
-
}, [
|
|
2389
|
-
|
|
2390
|
-
if (showPlaybackRateControl === true) {
|
|
2391
|
-
return [0.5, 0.8, 1, 1.2, 1.5, 1.8, 2, 2.5, 3];
|
|
2392
|
-
}
|
|
2393
|
-
if (Array.isArray(showPlaybackRateControl)) {
|
|
2394
|
-
for (const rate of showPlaybackRateControl) {
|
|
2395
|
-
if (typeof rate !== "number") {
|
|
2396
|
-
throw new Error("Every item in showPlaybackRateControl must be a number");
|
|
2397
|
-
}
|
|
2398
|
-
if (rate <= 0) {
|
|
2399
|
-
throw new Error("Every item in showPlaybackRateControl must be positive");
|
|
2400
|
-
}
|
|
2401
|
-
}
|
|
2402
|
-
return showPlaybackRateControl;
|
|
2403
|
-
}
|
|
2503
|
+
}, [unlicensed]);
|
|
2504
|
+
if (!unlicensed) {
|
|
2404
2505
|
return null;
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
const onDoubleClickIfContainer = useCallback7((e) => {
|
|
2415
|
-
if (e.target === ref.current || e.target === flexRef.current) {
|
|
2416
|
-
onDoubleClick?.(e);
|
|
2417
|
-
}
|
|
2418
|
-
}, [onDoubleClick]);
|
|
2419
|
-
return /* @__PURE__ */ jsxs8("div", {
|
|
2420
|
-
ref,
|
|
2421
|
-
style: containerCss,
|
|
2422
|
-
onPointerDown: onPointerDownIfContainer,
|
|
2423
|
-
onDoubleClick: onDoubleClickIfContainer,
|
|
2424
|
-
children: [
|
|
2425
|
-
/* @__PURE__ */ jsxs8("div", {
|
|
2426
|
-
ref: flexRef,
|
|
2427
|
-
style: controlsRow,
|
|
2428
|
-
children: [
|
|
2429
|
-
/* @__PURE__ */ jsxs8("div", {
|
|
2430
|
-
style: leftPartStyle,
|
|
2431
|
-
children: [
|
|
2432
|
-
/* @__PURE__ */ jsx11("button", {
|
|
2433
|
-
ref: playButtonRef,
|
|
2434
|
-
type: "button",
|
|
2435
|
-
style: playerButtonStyle,
|
|
2436
|
-
onClick: toggle,
|
|
2437
|
-
"aria-label": playing ? "Pause video" : "Play video",
|
|
2438
|
-
title: playing ? "Pause video" : "Play video",
|
|
2439
|
-
children: renderPlayPauseButton === null ? /* @__PURE__ */ jsx11(DefaultPlayPauseButton, {
|
|
2440
|
-
buffering,
|
|
2441
|
-
playing
|
|
2442
|
-
}) : renderPlayPauseButton({
|
|
2443
|
-
playing,
|
|
2444
|
-
isBuffering: buffering
|
|
2445
|
-
}) ?? /* @__PURE__ */ jsx11(DefaultPlayPauseButton, {
|
|
2446
|
-
buffering,
|
|
2447
|
-
playing
|
|
2448
|
-
})
|
|
2449
|
-
}),
|
|
2450
|
-
showVolumeControls ? /* @__PURE__ */ jsxs8(Fragment2, {
|
|
2451
|
-
children: [
|
|
2452
|
-
/* @__PURE__ */ jsx11("div", {
|
|
2453
|
-
style: xSpacer
|
|
2454
|
-
}),
|
|
2455
|
-
/* @__PURE__ */ jsx11(MediaVolumeSlider, {
|
|
2456
|
-
renderMuteButton,
|
|
2457
|
-
renderVolumeSlider,
|
|
2458
|
-
displayVerticalVolumeSlider
|
|
2459
|
-
})
|
|
2460
|
-
]
|
|
2461
|
-
}) : null,
|
|
2462
|
-
/* @__PURE__ */ jsx11("div", {
|
|
2463
|
-
style: xSpacer
|
|
2464
|
-
}),
|
|
2465
|
-
/* @__PURE__ */ jsx11(PlayerTimeLabel, {
|
|
2466
|
-
durationInFrames,
|
|
2467
|
-
fps,
|
|
2468
|
-
maxTimeLabelWidth
|
|
2469
|
-
}),
|
|
2470
|
-
/* @__PURE__ */ jsx11("div", {
|
|
2471
|
-
style: xSpacer
|
|
2472
|
-
})
|
|
2473
|
-
]
|
|
2474
|
-
}),
|
|
2475
|
-
/* @__PURE__ */ jsx11("div", {
|
|
2476
|
-
style: flex1
|
|
2477
|
-
}),
|
|
2478
|
-
customControlsElement,
|
|
2479
|
-
customControlsElement && playbackRates && canvasSize ? /* @__PURE__ */ jsx11("div", {
|
|
2480
|
-
style: xSpacer
|
|
2481
|
-
}) : null,
|
|
2482
|
-
playbackRates && canvasSize && /* @__PURE__ */ jsx11(PlaybackrateControl, {
|
|
2483
|
-
canvasSize,
|
|
2484
|
-
playbackRates
|
|
2485
|
-
}),
|
|
2486
|
-
playbackRates && supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx11("div", {
|
|
2487
|
-
style: xSpacer
|
|
2488
|
-
}) : null,
|
|
2489
|
-
/* @__PURE__ */ jsx11("div", {
|
|
2490
|
-
style: fullscreen,
|
|
2491
|
-
children: supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx11("button", {
|
|
2492
|
-
type: "button",
|
|
2493
|
-
"aria-label": isFullscreen ? "Exit fullscreen" : "Enter Fullscreen",
|
|
2494
|
-
title: isFullscreen ? "Exit fullscreen" : "Enter Fullscreen",
|
|
2495
|
-
style: playerButtonStyle,
|
|
2496
|
-
onClick: isFullscreen ? onExitFullscreenButtonClick : onFullscreenButtonClick,
|
|
2497
|
-
children: renderFullscreenButton === null ? /* @__PURE__ */ jsx11(FullscreenIcon, {
|
|
2498
|
-
isFullscreen
|
|
2499
|
-
}) : renderFullscreenButton({ isFullscreen })
|
|
2500
|
-
}) : null
|
|
2501
|
-
})
|
|
2502
|
-
]
|
|
2503
|
-
}),
|
|
2504
|
-
/* @__PURE__ */ jsx11("div", {
|
|
2505
|
-
style: ySpacer
|
|
2506
|
-
}),
|
|
2507
|
-
/* @__PURE__ */ jsx11(PlayerSeekBar, {
|
|
2508
|
-
onSeekEnd,
|
|
2509
|
-
onSeekStart,
|
|
2510
|
-
durationInFrames,
|
|
2511
|
-
inFrame,
|
|
2512
|
-
outFrame
|
|
2513
|
-
})
|
|
2514
|
-
]
|
|
2506
|
+
}
|
|
2507
|
+
return /* @__PURE__ */ jsx11("div", {
|
|
2508
|
+
style,
|
|
2509
|
+
className: "warning-banner",
|
|
2510
|
+
children: /* @__PURE__ */ jsx11("a", {
|
|
2511
|
+
style: { color: "white" },
|
|
2512
|
+
href: "https://github.com/remotion-dev/remotion/pull/4589",
|
|
2513
|
+
children: "Remotion Unlicensed – Contact hi@remotion.dev"
|
|
2514
|
+
})
|
|
2515
2515
|
});
|
|
2516
2516
|
};
|
|
2517
2517
|
|
|
@@ -4048,6 +4048,7 @@ var PlayerInternals = {
|
|
|
4048
4048
|
updateAllElementsSizes,
|
|
4049
4049
|
PlayerEmitterProvider,
|
|
4050
4050
|
BufferingIndicator,
|
|
4051
|
+
PlayerControls: Controls,
|
|
4051
4052
|
TimelineSequenceObserverContext,
|
|
4052
4053
|
CanvasOverlayContext,
|
|
4053
4054
|
CanvasContentContext
|