UNPKG

2.84 kBMarkdownView Raw
1### Remotion Player
2
3[![NPM Version](https://img.shields.io/npm/v/@remotion/player.svg?style=flat)](https://www.npmjs.org/package/@remotion/player)
4[![NPM Downloads](https://img.shields.io/npm/dm/@remotion/player.svg?style=flat)](https://npmcharts.com/compare/@remotion/player?minimal=true)
5[![Install Size](https://packagephobia.now.sh/badge?p=@remotion/player)](https://packagephobia.now.sh/result?p=@remotion/player)
6
7The `@remotion/player` package allows you to embed a video powered by Remotion in a React application.
8
9## Installation and prerequisites
10
11The dependencies that Remotion requires you to have pre-installed on your machine are Node.js and FFMPEG. You can take a look at this [guide](https://github.com/adaptlearning/adapt_authoring/wiki/Installing-FFmpeg) on how to get FFMPEG on your machine.
12
13Install this package and Remotion with the package manager that you use for project:
14
15```bash
16npm i remotion @remotion/player
17```
18
19```bash
20yarn add remotion @remotion/player
21```
22
23```bash
24pnpm i remotion @remotion/player
25```
26
27> Make sure all Remotion packages you install (`remotion`, `@remotion/player`, `@remotion/gif`...) [have the same version](https://remotion.dev/docs/version-mismatch).
28
29## Getting started
30
31Now that you have this package as a dependency in your React project, it is time to see some of the basic examples that you can spin up with this package.
32
33The `@remotion/player` package can be imported as a React component from the library, which you can make use of in your components, either by nesting it in a custom component of yours or simply making it a standalone component.
34
35```javascript
36// components/MyVideo.js
37import React from 'react';
38import {useCurrentFrame} from 'remotion';
39
40const MyVideo = () => {
41 const frame = useCurrentFrame();
42
43 return (
44 <div
45 style={{
46 flex: 1,
47 textAlign: 'center',
48 fontSize: '7em',
49 }}
50 >
51 The current frame is {frame}.
52 </div>
53 );
54};
55```
56
57```javascript
58import {Player} from '@remotion/player';
59import {MyVideo} from '../components/MyVideo';
60
61export const App = () => {
62 return (
63 <Player
64 component={MyVideo}
65 durationInFrames={120}
66 compositionWidth={1920}
67 compositionHeight={1080}
68 fps={30}
69 />
70 );
71};
72```
73
74## API
75
76The most important props accepted:
77
78| Props | Function |
79| ----------------- | ---------------------------------------- |
80| component | A React component that renders the video |
81| durationInFrames | The duration of the video in frames |
82| compositionHeight | The height of the composition in pixels |
83| compositionWidth | The width of the composition in pixels |
84| fps | The frame rate of the video |
85
86For a complete reference of the available props, refer to [@remotion/player API](https://www.remotion.dev/docs/player/player).