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