packages/docs/docs/player/player-examples.mdx
// @allowUmdGlobalAccess
// @filename: ./remotion/MyVideo.tsx
export const MyVideo = () => <></>;
// @filename: index.tsx
// ---cut---
import { Player } from "@remotion/player";
import { MyVideo } from "./remotion/MyVideo";
export const App: React.FC = () => {
return (
<Player
component={MyVideo}
durationInFrames={120}
compositionWidth={1920}
compositionHeight={1080}
fps={30}
/>
);
};
// @allowUmdGlobalAccess
// @filename: ./remotion/MyVideo.tsx
export const MyVideo = () => <></>;
// @filename: index.tsx
// ---cut---
import { Player } from "@remotion/player";
import { MyVideo } from "./remotion/MyVideo";
export const App: React.FC = () => {
return (
<Player
component={MyVideo}
durationInFrames={120}
compositionWidth={1920}
compositionHeight={1080}
fps={30}
controls
/>
);
};
// @allowUmdGlobalAccess
// @filename: ./remotion/MyVideo.tsx
export const MyVideo = () => <></>;
// @filename: index.tsx
// ---cut---
import { Player } from "@remotion/player";
import { MyVideo } from "./remotion/MyVideo";
export const App: React.FC = () => {
return (
<Player
component={MyVideo}
durationInFrames={120}
compositionWidth={1920}
compositionHeight={1080}
fps={30}
controls
loop
/>
);
};
// @allowUmdGlobalAccess
// @filename: ./remotion/MyVideo.tsx
export const MyVideo = () => <></>;
// @filename: index.tsx
// ---cut---
import { Player } from "@remotion/player";
import { MyVideo } from "./remotion/MyVideo";
export const App: React.FC = () => {
return (
<Player
component={MyVideo}
durationInFrames={120}
compositionWidth={1920}
compositionHeight={1080}
fps={30}
controls
loop
style={{
width: 1280,
height: 720,
}}
/>
);
};
:::note See Scaling for more ways to scale the Player. :::
// @allowUmdGlobalAccess
// @filename: ./remotion/MyVideo.tsx
export const MyVideo = () => <></>;
// @filename: index.tsx
// ---cut---
import { Player } from "@remotion/player";
import { MyVideo } from "./remotion/MyVideo";
export const App: React.FC = () => {
return (
<Player
component={MyVideo}
durationInFrames={120}
compositionWidth={1920}
compositionHeight={1080}
fps={30}
controls
loop
style={{
width: 1280,
height: 720,
}}
autoPlay
/>
);
};
:::tip You need to be wary of the browser's autoplay policy. In most browsers, you cannot autoplay an audio file or a video with audio. :::
// @allowUmdGlobalAccess
// @filename: ./remotion/MyVideo.tsx
export const MyVideo = () => <></>;
// @filename: index.tsx
// ---cut---
import { Player, PlayerRef } from "@remotion/player";
import { useCallback, useRef } from "react";
import { MyVideo } from "./remotion/MyVideo";
export const App: React.FC = () => {
const playerRef = useRef<PlayerRef>(null);
const seekToMiddle = useCallback(() => {
const { current } = playerRef;
if (!current) {
return;
}
current.seekTo(60);
}, []);
return (
<Player
ref={playerRef}
component={MyVideo}
durationInFrames={120}
compositionWidth={1920}
compositionHeight={1080}
fps={30}
/>
);
};
// @allowUmdGlobalAccess
// @filename: ./remotion/MyVideo.tsx
export const MyVideo = () => <></>;
// @filename: index.tsx
// ---cut---
import { Player, PlayerRef } from "@remotion/player";
import { useEffect, useRef } from "react";
import { MyVideo } from "./remotion/MyVideo";
export const App: React.FC = () => {
const playerRef = useRef<PlayerRef>(null);
useEffect(() => {
const { current } = playerRef;
if (!current) {
return;
}
const listener = () => {
console.log("paused");
};
current.addEventListener("pause", listener);
return () => {
current.removeEventListener("pause", listener);
};
}, []);
return (
<Player
ref={playerRef}
component={MyVideo}
durationInFrames={120}
compositionWidth={1920}
compositionHeight={1080}
fps={30}
/>
);
};
// @allowUmdGlobalAccess
// @filename: ./remotion/MyVideo.tsx
export const MyVideo = () => <></>;
// @filename: index.tsx
// ---cut---
import { Player } from "@remotion/player";
import { useState, useMemo } from "react";
import { MyVideo } from "./remotion/MyVideo";
export const App: React.FC = () => {
// Connect the state to a text field
const [text, setText] = useState("world");
const inputProps = useMemo(() => {
return {
text,
};
}, [text]);
return (
<Player
component={MyVideo}
durationInFrames={120}
compositionWidth={1920}
compositionHeight={1080}
fps={30}
inputProps={inputProps}
/>
);
};
// @allowUmdGlobalAccess
// @filename: ./remotion/MyVideo.tsx
export const MyVideo = () => <></>;
// @filename: index.tsx
// ---cut---
import { Player } from "@remotion/player";
import { MyVideo } from "./remotion/MyVideo";
export const App: React.FC = () => {
return (
<Player
component={MyVideo}
durationInFrames={120}
compositionWidth={1920}
compositionHeight={1080}
fps={30}
loop
inFrame={30}
outFrame={60}
/>
);
};
// @allowUmdGlobalAccess
// @filename: ./remotion/MyVideo.tsx
export default () => <></>;
// @filename: index.tsx
// ---cut---
import { Player } from "@remotion/player";
import { useCallback } from "react";
export const App: React.FC = () => {
const lazyComponent = useCallback(() => {
return import("./remotion/MyVideo");
}, []);
return (
<Player
lazyComponent={lazyComponent}
durationInFrames={120}
compositionWidth={1920}
compositionHeight={1080}
fps={30}
loop
/>
);
};