@remotion/player 4.0.0-lambda.1 → 4.0.0-newpathfunctions.13
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/LICENSE.md +8 -8
- package/README.md +1 -1
- package/dist/MediaVolumeSlider.d.ts +4 -1
- package/dist/MediaVolumeSlider.js +80 -55
- package/dist/Player.d.ts +20 -15
- package/dist/Player.js +24 -70
- package/dist/PlayerControls.d.ts +29 -2
- package/dist/PlayerControls.js +66 -15
- package/dist/PlayerSeekBar.d.ts +4 -0
- package/dist/PlayerSeekBar.js +35 -11
- package/dist/PlayerUI.d.ts +18 -9
- package/dist/PlayerUI.js +89 -74
- package/dist/SharedPlayerContext.d.ts +14 -0
- package/dist/SharedPlayerContext.js +72 -0
- package/dist/Thumbnail.d.ts +20 -0
- package/dist/Thumbnail.js +42 -0
- package/dist/ThumbnailUI.d.ts +11 -0
- package/dist/ThumbnailUI.js +107 -0
- package/dist/calculate-next-frame.d.ts +0 -0
- package/dist/calculate-next-frame.js +0 -0
- package/dist/calculate-scale.d.ts +30 -5
- package/dist/calculate-scale.js +65 -4
- package/dist/cjs/MediaVolumeSlider.d.ts +5 -0
- package/dist/cjs/MediaVolumeSlider.js +118 -0
- package/dist/cjs/Player.d.ts +43 -0
- package/dist/cjs/Player.js +143 -0
- package/dist/cjs/PlayerControls.d.ts +41 -0
- package/dist/cjs/PlayerControls.js +152 -0
- package/dist/cjs/PlayerSeekBar.d.ts +8 -0
- package/dist/cjs/PlayerSeekBar.js +146 -0
- package/dist/cjs/PlayerUI.d.ts +38 -0
- package/dist/cjs/PlayerUI.js +308 -0
- package/dist/cjs/SharedPlayerContext.d.ts +14 -0
- package/dist/cjs/SharedPlayerContext.js +72 -0
- package/dist/cjs/Thumbnail.d.ts +20 -0
- package/dist/cjs/Thumbnail.js +42 -0
- package/dist/cjs/ThumbnailUI.d.ts +11 -0
- package/dist/cjs/ThumbnailUI.js +107 -0
- package/dist/cjs/calculate-next-frame.d.ts +14 -0
- package/dist/cjs/calculate-next-frame.js +28 -0
- package/dist/cjs/calculate-scale.d.ts +39 -0
- package/dist/cjs/calculate-scale.js +85 -0
- package/dist/cjs/emitter-context.d.ts +4 -0
- package/dist/cjs/emitter-context.js +9 -0
- package/dist/cjs/error-boundary.d.ts +19 -0
- package/dist/cjs/error-boundary.js +39 -0
- package/dist/cjs/event-emitter.d.ts +66 -0
- package/dist/cjs/event-emitter.js +87 -0
- package/dist/cjs/format-time.d.ts +1 -0
- package/dist/cjs/format-time.js +9 -0
- package/dist/cjs/icons.d.ts +10 -0
- package/dist/cjs/icons.js +50 -0
- package/dist/cjs/index.d.ts +60 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/player-css-classname.d.ts +1 -0
- package/dist/cjs/player-css-classname.js +4 -0
- package/dist/cjs/player-methods.d.ts +24 -0
- package/dist/cjs/player-methods.js +2 -0
- package/dist/cjs/test/index.test.d.ts +1 -0
- package/dist/cjs/test/index.test.js +9 -0
- package/dist/cjs/test/test-utils.d.ts +6 -0
- package/dist/cjs/test/test-utils.js +32 -0
- package/dist/cjs/test/validate-in-out-frames.test.d.ts +1 -0
- package/dist/cjs/test/validate-in-out-frames.test.js +56 -0
- package/dist/cjs/test/validate-prop.test.d.ts +1 -0
- package/dist/cjs/test/validate-prop.test.js +131 -0
- package/dist/cjs/use-hover-state.d.ts +1 -0
- package/dist/cjs/use-hover-state.js +27 -0
- package/dist/cjs/use-playback.d.ts +7 -0
- package/dist/cjs/use-playback.js +92 -0
- package/dist/cjs/use-player.d.ts +19 -0
- package/dist/cjs/use-player.js +132 -0
- package/dist/cjs/use-thumbnail.d.ts +6 -0
- package/dist/cjs/use-thumbnail.js +18 -0
- package/dist/cjs/use-video-controls-resize.d.ts +7 -0
- package/dist/cjs/use-video-controls-resize.js +36 -0
- package/dist/cjs/utils/calculate-player-size.d.ts +9 -0
- package/dist/cjs/utils/calculate-player-size.js +29 -0
- package/dist/cjs/utils/cancellable-promise.d.ts +5 -0
- package/dist/cjs/utils/cancellable-promise.js +26 -0
- package/dist/cjs/utils/delay.d.ts +1 -0
- package/dist/cjs/utils/delay.js +6 -0
- package/dist/cjs/utils/is-node.d.ts +1 -0
- package/dist/cjs/utils/is-node.js +4 -0
- package/dist/cjs/utils/preview-size.d.ts +8 -0
- package/dist/cjs/utils/preview-size.js +2 -0
- package/dist/cjs/utils/props-if-has-props.d.ts +5 -0
- package/dist/cjs/utils/props-if-has-props.js +2 -0
- package/dist/cjs/utils/use-cancellable-promises.d.ts +7 -0
- package/dist/cjs/utils/use-cancellable-promises.js +21 -0
- package/dist/cjs/utils/use-click-prevention-on-double-click.d.ts +3 -0
- package/dist/cjs/utils/use-click-prevention-on-double-click.js +45 -0
- package/dist/cjs/utils/use-element-size.d.ts +16 -0
- package/dist/cjs/utils/use-element-size.js +98 -0
- package/dist/cjs/utils/validate-in-out-frame.d.ts +6 -0
- package/dist/cjs/utils/validate-in-out-frame.js +54 -0
- package/dist/cjs/utils/validate-initial-frame.d.ts +4 -0
- package/dist/cjs/utils/validate-initial-frame.js +27 -0
- package/dist/cjs/utils/validate-playbackrate.d.ts +1 -0
- package/dist/cjs/utils/validate-playbackrate.js +18 -0
- package/dist/cjs/volume-persistance.d.ts +2 -0
- package/dist/cjs/volume-persistance.js +19 -0
- package/dist/emitter-context.d.ts +2 -1
- package/dist/emitter-context.js +2 -1
- package/dist/error-boundary.d.ts +0 -0
- package/dist/error-boundary.js +0 -0
- package/dist/esm/MediaVolumeSlider.d.ts +5 -0
- package/dist/esm/MediaVolumeSlider.js +114 -0
- package/dist/esm/Player.d.ts +43 -0
- package/dist/esm/Player.js +136 -0
- package/dist/esm/PlayerControls.d.ts +41 -0
- package/dist/esm/PlayerControls.js +148 -0
- package/dist/esm/PlayerSeekBar.d.ts +8 -0
- package/dist/esm/PlayerSeekBar.js +142 -0
- package/dist/esm/PlayerUI.d.ts +38 -0
- package/dist/esm/PlayerUI.js +283 -0
- package/dist/esm/SharedPlayerContext.d.ts +14 -0
- package/dist/esm/SharedPlayerContext.js +68 -0
- package/dist/esm/Thumbnail.d.ts +20 -0
- package/dist/esm/Thumbnail.js +35 -0
- package/dist/esm/ThumbnailUI.d.ts +11 -0
- package/dist/esm/ThumbnailUI.js +82 -0
- package/dist/esm/calculate-next-frame.d.ts +14 -0
- package/dist/esm/calculate-next-frame.js +24 -0
- package/dist/esm/calculate-scale.d.ts +39 -0
- package/dist/esm/calculate-scale.js +77 -0
- package/dist/esm/emitter-context.d.ts +4 -0
- package/dist/esm/emitter-context.js +3 -0
- package/dist/esm/error-boundary.d.ts +19 -0
- package/dist/esm/error-boundary.js +32 -0
- package/dist/esm/event-emitter.d.ts +66 -0
- package/dist/esm/event-emitter.js +82 -0
- package/dist/esm/format-time.d.ts +1 -0
- package/dist/esm/format-time.js +5 -0
- package/dist/esm/icons.d.ts +10 -0
- package/dist/esm/icons.js +42 -0
- package/dist/esm/index.d.ts +60 -0
- package/dist/esm/index.js +20 -0
- package/dist/esm/player-css-classname.d.ts +1 -0
- package/dist/esm/player-css-classname.js +1 -0
- package/dist/esm/player-methods.d.ts +24 -0
- package/dist/esm/player-methods.js +1 -0
- package/dist/esm/test/index.test.d.ts +1 -0
- package/dist/esm/test/index.test.js +7 -0
- package/dist/esm/test/test-utils.d.ts +6 -0
- package/dist/esm/test/test-utils.js +14 -0
- package/dist/esm/test/validate-in-out-frames.test.d.ts +1 -0
- package/dist/esm/test/validate-in-out-frames.test.js +54 -0
- package/dist/esm/test/validate-prop.test.d.ts +1 -0
- package/dist/esm/test/validate-prop.test.js +129 -0
- package/dist/esm/use-hover-state.d.ts +1 -0
- package/dist/esm/use-hover-state.js +23 -0
- package/dist/esm/use-playback.d.ts +7 -0
- package/dist/esm/use-playback.js +88 -0
- package/dist/esm/use-player.d.ts +19 -0
- package/dist/esm/use-player.js +128 -0
- package/dist/esm/use-thumbnail.d.ts +6 -0
- package/dist/esm/use-thumbnail.js +14 -0
- package/dist/esm/use-video-controls-resize.d.ts +7 -0
- package/dist/esm/use-video-controls-resize.js +32 -0
- package/dist/esm/utils/calculate-player-size.d.ts +9 -0
- package/dist/esm/utils/calculate-player-size.js +25 -0
- package/dist/esm/utils/cancellable-promise.d.ts +5 -0
- package/dist/esm/utils/cancellable-promise.js +22 -0
- package/dist/esm/utils/delay.d.ts +1 -0
- package/dist/esm/utils/delay.js +2 -0
- package/dist/esm/utils/is-node.d.ts +1 -0
- package/dist/esm/utils/is-node.js +1 -0
- package/dist/esm/utils/preview-size.d.ts +8 -0
- package/dist/esm/utils/preview-size.js +1 -0
- package/dist/esm/utils/props-if-has-props.d.ts +5 -0
- package/dist/esm/utils/props-if-has-props.js +1 -0
- package/dist/esm/utils/use-cancellable-promises.d.ts +7 -0
- package/dist/esm/utils/use-cancellable-promises.js +18 -0
- package/dist/esm/utils/use-click-prevention-on-double-click.d.ts +3 -0
- package/dist/esm/utils/use-click-prevention-on-double-click.js +42 -0
- package/dist/esm/utils/use-element-size.d.ts +16 -0
- package/dist/esm/utils/use-element-size.js +93 -0
- package/dist/esm/utils/validate-in-out-frame.d.ts +6 -0
- package/dist/esm/utils/validate-in-out-frame.js +49 -0
- package/dist/esm/utils/validate-initial-frame.d.ts +4 -0
- package/dist/esm/utils/validate-initial-frame.js +23 -0
- package/dist/esm/utils/validate-playbackrate.d.ts +1 -0
- package/dist/esm/utils/validate-playbackrate.js +14 -0
- package/dist/esm/volume-persistance.d.ts +2 -0
- package/dist/esm/volume-persistance.js +14 -0
- package/dist/event-emitter.d.ts +33 -9
- package/dist/event-emitter.js +33 -1
- package/dist/format-time.d.ts +0 -0
- package/dist/format-time.js +0 -0
- package/dist/icons.d.ts +2 -1
- package/dist/icons.js +7 -7
- package/dist/index.d.ts +24 -9
- package/dist/index.js +5 -2
- package/dist/player-css-classname.d.ts +0 -1
- package/dist/player-css-classname.js +1 -2
- package/dist/player-methods.d.ts +8 -4
- package/dist/player-methods.js +0 -0
- package/dist/test/index.test.d.ts +0 -0
- package/dist/test/index.test.js +3 -2
- package/dist/test/test-utils.d.ts +2 -2
- package/dist/test/test-utils.js +0 -0
- package/dist/test/validate-in-out-frames.test.d.ts +1 -0
- package/dist/test/validate-in-out-frames.test.js +56 -0
- package/dist/test/validate-prop.test.d.ts +0 -0
- package/dist/test/validate-prop.test.js +24 -23
- package/dist/tsconfig-cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/use-hover-state.d.ts +0 -0
- package/dist/use-hover-state.js +0 -0
- package/dist/use-playback.d.ts +4 -1
- package/dist/use-playback.js +7 -3
- package/dist/use-player.d.ts +8 -3
- package/dist/use-player.js +23 -4
- package/dist/use-thumbnail.d.ts +6 -0
- package/dist/use-thumbnail.js +18 -0
- package/dist/use-video-controls-resize.d.ts +7 -0
- package/dist/use-video-controls-resize.js +36 -0
- package/dist/utils/calculate-player-size.d.ts +2 -2
- package/dist/utils/calculate-player-size.js +0 -0
- package/dist/utils/cancellable-promise.d.ts +0 -0
- package/dist/utils/cancellable-promise.js +0 -0
- package/dist/utils/delay.d.ts +0 -0
- package/dist/utils/delay.js +0 -0
- package/dist/utils/is-node.d.ts +0 -0
- package/dist/utils/is-node.js +0 -0
- package/dist/utils/preview-size.d.ts +8 -1
- package/dist/utils/preview-size.js +0 -0
- package/dist/utils/props-if-has-props.d.ts +5 -0
- package/dist/utils/props-if-has-props.js +2 -0
- package/dist/utils/use-cancellable-promises.d.ts +1 -1
- package/dist/utils/use-cancellable-promises.js +0 -0
- package/dist/utils/use-click-prevention-on-double-click.d.ts +1 -1
- package/dist/utils/use-click-prevention-on-double-click.js +0 -0
- package/dist/utils/use-element-size.d.ts +4 -0
- package/dist/utils/use-element-size.js +8 -0
- package/dist/utils/validate-in-out-frame.d.ts +6 -0
- package/dist/utils/validate-in-out-frame.js +54 -0
- package/dist/utils/validate-initial-frame.d.ts +4 -0
- package/dist/utils/validate-initial-frame.js +27 -0
- package/dist/utils/validate-playbackrate.d.ts +0 -0
- package/dist/utils/validate-playbackrate.js +0 -0
- package/dist/volume-persistance.d.ts +0 -0
- package/dist/volume-persistance.js +0 -0
- package/package.json +26 -17
- package/dist/MediaVolumeSlider.d.ts.map +0 -1
- package/dist/MediaVolumeSlider.js.map +0 -1
- package/dist/Player.d.ts.map +0 -1
- package/dist/Player.js.map +0 -1
- package/dist/PlayerControls.d.ts.map +0 -1
- package/dist/PlayerControls.js.map +0 -1
- package/dist/PlayerSeekBar.d.ts.map +0 -1
- package/dist/PlayerSeekBar.js.map +0 -1
- package/dist/PlayerUI.d.ts.map +0 -1
- package/dist/PlayerUI.js.map +0 -1
- package/dist/calculate-next-frame.d.ts.map +0 -1
- package/dist/calculate-next-frame.js.map +0 -1
- package/dist/calculate-scale.d.ts.map +0 -1
- package/dist/calculate-scale.js.map +0 -1
- package/dist/emitter-context.d.ts.map +0 -1
- package/dist/emitter-context.js.map +0 -1
- package/dist/error-boundary.d.ts.map +0 -1
- package/dist/error-boundary.js.map +0 -1
- package/dist/event-emitter.d.ts.map +0 -1
- package/dist/event-emitter.js.map +0 -1
- package/dist/format-time.d.ts.map +0 -1
- package/dist/format-time.js.map +0 -1
- package/dist/icons.d.ts.map +0 -1
- package/dist/icons.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/player-css-classname.d.ts.map +0 -1
- package/dist/player-css-classname.js.map +0 -1
- package/dist/player-methods.d.ts.map +0 -1
- package/dist/player-methods.js.map +0 -1
- package/dist/test/index.test.d.ts.map +0 -1
- package/dist/test/index.test.js.map +0 -1
- package/dist/test/test-utils.d.ts.map +0 -1
- package/dist/test/test-utils.js.map +0 -1
- package/dist/test/validate-prop.test.d.ts.map +0 -1
- package/dist/test/validate-prop.test.js.map +0 -1
- package/dist/use-hover-state.d.ts.map +0 -1
- package/dist/use-hover-state.js.map +0 -1
- package/dist/use-playback.d.ts.map +0 -1
- package/dist/use-playback.js.map +0 -1
- package/dist/use-player.d.ts.map +0 -1
- package/dist/use-player.js.map +0 -1
- package/dist/utils/browser-supports-fullscreen.d.ts +0 -11
- package/dist/utils/browser-supports-fullscreen.d.ts.map +0 -1
- package/dist/utils/browser-supports-fullscreen.js +0 -5
- package/dist/utils/browser-supports-fullscreen.js.map +0 -1
- package/dist/utils/calculate-player-size.d.ts.map +0 -1
- package/dist/utils/calculate-player-size.js.map +0 -1
- package/dist/utils/cancellable-promise.d.ts.map +0 -1
- package/dist/utils/cancellable-promise.js.map +0 -1
- package/dist/utils/delay.d.ts.map +0 -1
- package/dist/utils/delay.js.map +0 -1
- package/dist/utils/is-node.d.ts.map +0 -1
- package/dist/utils/is-node.js.map +0 -1
- package/dist/utils/preview-size.d.ts.map +0 -1
- package/dist/utils/preview-size.js.map +0 -1
- package/dist/utils/use-cancellable-promises.d.ts.map +0 -1
- package/dist/utils/use-cancellable-promises.js.map +0 -1
- package/dist/utils/use-click-prevention-on-double-click.d.ts.map +0 -1
- package/dist/utils/use-click-prevention-on-double-click.js.map +0 -1
- package/dist/utils/use-element-size.d.ts.map +0 -1
- package/dist/utils/use-element-size.js.map +0 -1
- package/dist/utils/validate-playbackrate.d.ts.map +0 -1
- package/dist/utils/validate-playbackrate.js.map +0 -1
- package/dist/volume-persistance.d.ts.map +0 -1
- package/dist/volume-persistance.js.map +0 -1
package/LICENSE.md
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
# Remotion License
|
|
2
2
|
|
|
3
|
-
Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion create videos for free (even commercial), while a company license is required for for-profit
|
|
3
|
+
Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion to create videos for free (even commercial), while a company license is required for for-profit organizations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
|
|
4
4
|
|
|
5
5
|
- [Free license](#free-license)
|
|
6
6
|
- [Company license](#company-license)
|
|
7
7
|
|
|
8
8
|
## Free license
|
|
9
9
|
|
|
10
|
-
Copyright ©
|
|
10
|
+
Copyright © 2023 [Remotion](https://www.remotion.dev/)
|
|
11
11
|
|
|
12
12
|
### Eligibility
|
|
13
13
|
|
|
14
14
|
You are eligible to use Remotion for free if you are:
|
|
15
15
|
|
|
16
16
|
- an individual
|
|
17
|
-
- a for-profit
|
|
18
|
-
- a non-profit or not-for-profit
|
|
17
|
+
- a for-profit organization with up to 3 employees
|
|
18
|
+
- a non-profit or not-for-profit organization
|
|
19
19
|
- evaluating whether Remotion is a good fit, and are not yet using it in a commercial way
|
|
20
20
|
|
|
21
21
|
### Allowed use cases
|
|
22
22
|
|
|
23
|
-
Permission is hereby granted, free of charge, to any person eligible for the "Free license", to use the software non-commercially or commercially for the purpose of creating videos and images and to modify
|
|
23
|
+
Permission is hereby granted, free of charge, to any person eligible for the "Free license", to use the software non-commercially or commercially for the purpose of creating videos and images and to modify the software to their own liking, for the purpose of fulfilling their custom use case or to contribute bug fixes or improvements back to Remotion.
|
|
24
24
|
|
|
25
25
|
### Disallowed use cases
|
|
26
26
|
|
|
27
|
-
It is not allowed to copy or modify Remotion code for the purpose of selling, renting, licensing, relicensing, sublicensing your own derivate of Remotion.
|
|
27
|
+
It is not allowed to copy or modify Remotion code for the purpose of selling, renting, licensing, relicensing, or sublicensing your own derivate of Remotion.
|
|
28
28
|
|
|
29
29
|
### Warranty notice
|
|
30
30
|
|
|
31
|
-
The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and
|
|
31
|
+
The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the author or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
|
|
32
32
|
|
|
33
33
|
### Support
|
|
34
34
|
|
|
@@ -36,6 +36,6 @@ Support is provided on a best-we-can-do basis via GitHub Issues and Discord.
|
|
|
36
36
|
|
|
37
37
|
## Company license
|
|
38
38
|
|
|
39
|
-
You are required to obtain a company license to use Remotion if you are not within the group of entities eligible for a free license. This license will enable you to use Remotion for the allowed use cases specified in the free license, and give you access to prioritized support.
|
|
39
|
+
You are required to obtain a company license to use Remotion if you are not within the group of entities eligible for a free license. This license will enable you to use Remotion for the allowed use cases specified in the free license, and give you access to prioritized support (read the [Support Policy](/docs/support)).
|
|
40
40
|
|
|
41
41
|
Visit [companies.remotion.dev](https://companies.remotion.dev) for pricing and to buy a license.
|
package/README.md
CHANGED
|
@@ -83,4 +83,4 @@ The most important props accepted:
|
|
|
83
83
|
| compositionWidth | The width of the composition in pixels |
|
|
84
84
|
| fps | The frame rate of the video |
|
|
85
85
|
|
|
86
|
-
For a complete reference of the available props, refer to [@remotion/player API](https://www.remotion.dev/docs/player/
|
|
86
|
+
For a complete reference of the available props, refer to [@remotion/player API](https://www.remotion.dev/docs/player/player).
|
|
@@ -1,72 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MediaVolumeSlider = void 0;
|
|
3
|
+
exports.MediaVolumeSlider = exports.VOLUME_SLIDER_WIDTH = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const remotion_1 = require("remotion");
|
|
7
7
|
const icons_1 = require("./icons");
|
|
8
|
-
const player_css_classname_1 = require("./player-css-classname");
|
|
9
8
|
const use_hover_state_1 = require("./use-hover-state");
|
|
10
9
|
const BAR_HEIGHT = 5;
|
|
11
10
|
const KNOB_SIZE = 12;
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const sliderStyle = `
|
|
15
|
-
${scope} {
|
|
16
|
-
-webkit-appearance: none;
|
|
17
|
-
background-color: rgba(255, 255, 255, 0.5);
|
|
18
|
-
border-radius: ${BAR_HEIGHT / 2}px;
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
height: ${BAR_HEIGHT}px;
|
|
21
|
-
margin-left: 5px;
|
|
22
|
-
width: ${VOLUME_SLIDER_WIDTH}px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
${scope}::-webkit-slider-thumb {
|
|
26
|
-
-webkit-appearance: none;
|
|
27
|
-
background-color: white;
|
|
28
|
-
border-radius: ${KNOB_SIZE / 2}px;
|
|
29
|
-
box-shadow: 0 0 2px black;
|
|
30
|
-
height: ${KNOB_SIZE}px;
|
|
31
|
-
width: ${KNOB_SIZE}px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
${scope}::-moz-range-thumb {
|
|
35
|
-
-webkit-appearance: none;
|
|
36
|
-
background-color: white;
|
|
37
|
-
border-radius: ${KNOB_SIZE / 2}px;
|
|
38
|
-
box-shadow: 0 0 2px black;
|
|
39
|
-
height: ${KNOB_SIZE}px;
|
|
40
|
-
width: ${KNOB_SIZE}px;
|
|
41
|
-
}
|
|
42
|
-
`;
|
|
43
|
-
remotion_1.Internals.CSSUtils.injectCSS(sliderStyle);
|
|
44
|
-
const parentDivStyle = {
|
|
45
|
-
display: 'inline-flex',
|
|
46
|
-
background: 'none',
|
|
47
|
-
border: 'none',
|
|
48
|
-
padding: '6px',
|
|
49
|
-
justifyContent: 'center',
|
|
50
|
-
alignItems: 'center',
|
|
51
|
-
touchAction: 'none',
|
|
52
|
-
};
|
|
53
|
-
const volumeContainer = {
|
|
54
|
-
display: 'inline',
|
|
55
|
-
width: icons_1.ICON_SIZE,
|
|
56
|
-
height: icons_1.ICON_SIZE,
|
|
57
|
-
cursor: 'pointer',
|
|
58
|
-
appearance: 'none',
|
|
59
|
-
background: 'none',
|
|
60
|
-
border: 'none',
|
|
61
|
-
padding: 0,
|
|
62
|
-
};
|
|
63
|
-
const MediaVolumeSlider = () => {
|
|
11
|
+
exports.VOLUME_SLIDER_WIDTH = 100;
|
|
12
|
+
const MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
|
|
64
13
|
const [mediaMuted, setMediaMuted] = remotion_1.Internals.useMediaMutedState();
|
|
65
14
|
const [mediaVolume, setMediaVolume] = remotion_1.Internals.useMediaVolumeState();
|
|
66
15
|
const [focused, setFocused] = (0, react_1.useState)(false);
|
|
67
16
|
const parentDivRef = (0, react_1.useRef)(null);
|
|
68
17
|
const inputRef = (0, react_1.useRef)(null);
|
|
69
18
|
const hover = (0, use_hover_state_1.useHoverState)(parentDivRef);
|
|
19
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
20
|
+
const randomId = typeof react_1.useId === 'undefined' ? 'volume-slider' : (0, react_1.useId)();
|
|
21
|
+
const [randomClass] = (0, react_1.useState)(() => `__remotion-volume-slider-${(0, remotion_1.random)(randomId)}`.replace('.', ''));
|
|
70
22
|
const isMutedOrZero = mediaMuted || mediaVolume === 0;
|
|
71
23
|
const onVolumeChange = (e) => {
|
|
72
24
|
setMediaVolume(parseFloat(e.target.value));
|
|
@@ -88,6 +40,79 @@ const MediaVolumeSlider = () => {
|
|
|
88
40
|
}
|
|
89
41
|
setMediaMuted((mute) => !mute);
|
|
90
42
|
}, [mediaVolume, setMediaMuted, setMediaVolume]);
|
|
91
|
-
|
|
43
|
+
const parentDivStyle = (0, react_1.useMemo)(() => {
|
|
44
|
+
return {
|
|
45
|
+
display: 'inline-flex',
|
|
46
|
+
background: 'none',
|
|
47
|
+
border: 'none',
|
|
48
|
+
padding: '6px',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
touchAction: 'none',
|
|
52
|
+
...(displayVerticalVolumeSlider && { position: 'relative' }),
|
|
53
|
+
};
|
|
54
|
+
}, [displayVerticalVolumeSlider]);
|
|
55
|
+
const volumeContainer = (0, react_1.useMemo)(() => {
|
|
56
|
+
return {
|
|
57
|
+
display: 'inline',
|
|
58
|
+
width: icons_1.ICON_SIZE,
|
|
59
|
+
height: icons_1.ICON_SIZE,
|
|
60
|
+
cursor: 'pointer',
|
|
61
|
+
appearance: 'none',
|
|
62
|
+
background: 'none',
|
|
63
|
+
border: 'none',
|
|
64
|
+
padding: 0,
|
|
65
|
+
};
|
|
66
|
+
}, []);
|
|
67
|
+
const inputStyle = (0, react_1.useMemo)(() => {
|
|
68
|
+
const commonStyle = {
|
|
69
|
+
WebkitAppearance: 'none',
|
|
70
|
+
backgroundColor: 'rgba(255, 255, 255, 0.5)',
|
|
71
|
+
borderRadius: BAR_HEIGHT / 2,
|
|
72
|
+
cursor: 'pointer',
|
|
73
|
+
height: BAR_HEIGHT,
|
|
74
|
+
width: exports.VOLUME_SLIDER_WIDTH,
|
|
75
|
+
backgroundImage: `linear-gradient(
|
|
76
|
+
to right,
|
|
77
|
+
white ${mediaVolume * 100}%, rgba(255, 255, 255, 0) ${mediaVolume * 100}%
|
|
78
|
+
)`,
|
|
79
|
+
};
|
|
80
|
+
if (displayVerticalVolumeSlider) {
|
|
81
|
+
return {
|
|
82
|
+
...commonStyle,
|
|
83
|
+
transform: `rotate(-90deg)`,
|
|
84
|
+
position: 'absolute',
|
|
85
|
+
bottom: icons_1.ICON_SIZE + exports.VOLUME_SLIDER_WIDTH / 2 + 5,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
...commonStyle,
|
|
90
|
+
marginLeft: 5,
|
|
91
|
+
};
|
|
92
|
+
}, [displayVerticalVolumeSlider, mediaVolume]);
|
|
93
|
+
const sliderStyle = `
|
|
94
|
+
.${randomClass}::-webkit-slider-thumb {
|
|
95
|
+
-webkit-appearance: none;
|
|
96
|
+
background-color: white;
|
|
97
|
+
border-radius: ${KNOB_SIZE / 2}px;
|
|
98
|
+
box-shadow: 0 0 2px black;
|
|
99
|
+
height: ${KNOB_SIZE}px;
|
|
100
|
+
width: ${KNOB_SIZE}px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.${randomClass}::-moz-range-thumb {
|
|
104
|
+
-webkit-appearance: none;
|
|
105
|
+
background-color: white;
|
|
106
|
+
border-radius: ${KNOB_SIZE / 2}px;
|
|
107
|
+
box-shadow: 0 0 2px black;
|
|
108
|
+
height: ${KNOB_SIZE}px;
|
|
109
|
+
width: ${KNOB_SIZE}px;
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
112
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: parentDivRef, style: parentDivStyle, children: [(0, jsx_runtime_1.jsx)("style", {
|
|
113
|
+
// eslint-disable-next-line react/no-danger
|
|
114
|
+
dangerouslySetInnerHTML: {
|
|
115
|
+
__html: sliderStyle,
|
|
116
|
+
} }), (0, jsx_runtime_1.jsx)("button", { "aria-label": isMutedOrZero ? 'Unmute sound' : 'Mute sound', title: isMutedOrZero ? 'Unmute sound' : 'Mute sound', onClick: onClick, onBlur: onBlur, onFocus: () => setFocused(true), style: volumeContainer, type: "button", children: isMutedOrZero ? (0, jsx_runtime_1.jsx)(icons_1.VolumeOffIcon, {}) : (0, jsx_runtime_1.jsx)(icons_1.VolumeOnIcon, {}) }), (focused || hover) && !mediaMuted ? ((0, jsx_runtime_1.jsx)("input", { ref: inputRef, "aria-label": "Change volume", className: randomClass, max: 1, min: 0, onBlur: () => setFocused(false), onChange: onVolumeChange, step: 0.01, type: "range", value: mediaVolume, style: inputStyle })) : null] }));
|
|
92
117
|
};
|
|
93
118
|
exports.MediaVolumeSlider = MediaVolumeSlider;
|
package/dist/Player.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
inputProps: Props;
|
|
9
|
-
};
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { CompProps } from 'remotion';
|
|
4
|
+
import type { PlayerRef } from './player-methods';
|
|
5
|
+
import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls';
|
|
6
|
+
import type { RenderLoading, RenderPoster } from './PlayerUI';
|
|
7
|
+
import type { PropsIfHasProps } from './utils/props-if-has-props';
|
|
10
8
|
export declare type ErrorFallback = (info: {
|
|
11
9
|
error: Error;
|
|
12
10
|
}) => React.ReactNode;
|
|
@@ -28,11 +26,18 @@ export declare type PlayerProps<T> = {
|
|
|
28
26
|
numberOfSharedAudioTags?: number;
|
|
29
27
|
playbackRate?: number;
|
|
30
28
|
renderLoading?: RenderLoading;
|
|
29
|
+
moveToBeginningWhenEnded?: boolean;
|
|
30
|
+
className?: string;
|
|
31
|
+
initialFrame?: number;
|
|
32
|
+
renderPoster?: RenderPoster;
|
|
33
|
+
showPosterWhenPaused?: boolean;
|
|
34
|
+
showPosterWhenEnded?: boolean;
|
|
35
|
+
showPosterWhenUnplayed?: boolean;
|
|
36
|
+
inFrame?: number | null;
|
|
37
|
+
outFrame?: number | null;
|
|
38
|
+
initiallyShowControls?: number | boolean;
|
|
39
|
+
renderPlayPauseButton?: RenderPlayPauseButton;
|
|
40
|
+
renderFullscreenButton?: RenderFullscreenButton;
|
|
31
41
|
} & PropsIfHasProps<T> & CompProps<T>;
|
|
32
|
-
export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) =>
|
|
33
|
-
export declare const PlayerFn: <T>({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls, loop, autoPlay, showVolumeControls, allowFullscreen, clickToPlay, doubleClickToFullscreen, spaceKeyToPlayOrPause, numberOfSharedAudioTags, errorFallback, playbackRate, renderLoading, ...componentProps }: PlayerProps<T>, ref: MutableRefObject<PlayerRef>) => JSX.Element;
|
|
34
|
-
declare module 'react' {
|
|
35
|
-
function forwardRef<T, P = {}>(render: (props: P, ref: React.MutableRefObject<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
|
|
36
|
-
}
|
|
42
|
+
export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) => ComponentType<T> | null;
|
|
37
43
|
export declare const Player: <T>(props: PlayerProps<T> & React.RefAttributes<PlayerRef>) => React.ReactElement | null;
|
|
38
|
-
export {};
|
package/dist/Player.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Player = exports.
|
|
6
|
+
exports.Player = exports.componentOrNullIfLazy = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const remotion_1 = require("remotion");
|
|
@@ -11,9 +11,10 @@ const emitter_context_1 = require("./emitter-context");
|
|
|
11
11
|
const event_emitter_1 = require("./event-emitter");
|
|
12
12
|
const player_css_classname_1 = require("./player-css-classname");
|
|
13
13
|
const PlayerUI_1 = __importDefault(require("./PlayerUI"));
|
|
14
|
+
const SharedPlayerContext_1 = require("./SharedPlayerContext");
|
|
15
|
+
const validate_in_out_frame_1 = require("./utils/validate-in-out-frame");
|
|
16
|
+
const validate_initial_frame_1 = require("./utils/validate-initial-frame");
|
|
14
17
|
const validate_playbackrate_1 = require("./utils/validate-playbackrate");
|
|
15
|
-
const volume_persistance_1 = require("./volume-persistance");
|
|
16
|
-
remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(`.${player_css_classname_1.PLAYER_CSS_CLASSNAME}`, '#fff'));
|
|
17
18
|
const componentOrNullIfLazy = (props) => {
|
|
18
19
|
if ('component' in props) {
|
|
19
20
|
return props.component;
|
|
@@ -21,7 +22,7 @@ const componentOrNullIfLazy = (props) => {
|
|
|
21
22
|
return null;
|
|
22
23
|
};
|
|
23
24
|
exports.componentOrNullIfLazy = componentOrNullIfLazy;
|
|
24
|
-
const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, numberOfSharedAudioTags = 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, ...componentProps }, ref) => {
|
|
25
|
+
const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, moveToBeginningWhenEnded = true, numberOfSharedAudioTags = 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, initialFrame, renderPoster, inFrame, outFrame, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, ...componentProps }, ref) => {
|
|
25
26
|
if (typeof window !== 'undefined') {
|
|
26
27
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
27
28
|
(0, react_1.useLayoutEffect)(() => {
|
|
@@ -41,13 +42,12 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
41
42
|
throw new TypeError(`'component' must not be the 'Composition' component. Pass your own React component directly, and set the duration, fps and dimensions as separate props. See https://www.remotion.dev/docs/player/examples for an example.`);
|
|
42
43
|
}
|
|
43
44
|
const component = remotion_1.Internals.useLazyComponent(componentProps);
|
|
44
|
-
|
|
45
|
+
(0, validate_initial_frame_1.validateInitialFrame)({ initialFrame, durationInFrames });
|
|
46
|
+
const [frame, setFrame] = (0, react_1.useState)(() => initialFrame !== null && initialFrame !== void 0 ? initialFrame : 0);
|
|
45
47
|
const [playing, setPlaying] = (0, react_1.useState)(false);
|
|
46
48
|
const [rootId] = (0, react_1.useState)('player-comp');
|
|
47
49
|
const [emitter] = (0, react_1.useState)(() => new event_emitter_1.PlayerEmitter());
|
|
48
50
|
const rootRef = (0, react_1.useRef)(null);
|
|
49
|
-
const [mediaMuted, setMediaMuted] = (0, react_1.useState)(false);
|
|
50
|
-
const [mediaVolume, setMediaVolume] = (0, react_1.useState)((0, volume_persistance_1.getPreferredVolume)());
|
|
51
51
|
const audioAndVideoTags = (0, react_1.useRef)([]);
|
|
52
52
|
const imperativePlaying = (0, react_1.useRef)(false);
|
|
53
53
|
if (typeof compositionHeight !== 'number') {
|
|
@@ -59,7 +59,12 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
59
59
|
remotion_1.Internals.validateDimension(compositionHeight, 'compositionHeight', 'of the <Player /> component');
|
|
60
60
|
remotion_1.Internals.validateDimension(compositionWidth, 'compositionWidth', 'of the <Player /> component');
|
|
61
61
|
remotion_1.Internals.validateDurationInFrames(durationInFrames, 'of the <Player/> component');
|
|
62
|
-
remotion_1.Internals.validateFps(fps, 'as a prop of the <Player/> component');
|
|
62
|
+
remotion_1.Internals.validateFps(fps, 'as a prop of the <Player/> component', false);
|
|
63
|
+
(0, validate_in_out_frame_1.validateInOutFrames)({
|
|
64
|
+
durationInFrames,
|
|
65
|
+
inFrame,
|
|
66
|
+
outFrame,
|
|
67
|
+
});
|
|
63
68
|
if (typeof controls !== 'boolean' && typeof controls !== 'undefined') {
|
|
64
69
|
throw new TypeError(`'controls' must be a boolean or undefined but got '${typeof controls}' instead`);
|
|
65
70
|
}
|
|
@@ -99,11 +104,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
99
104
|
(0, react_1.useEffect)(() => {
|
|
100
105
|
emitter.dispatchRatechange(playbackRate);
|
|
101
106
|
}, [emitter, playbackRate]);
|
|
102
|
-
|
|
103
|
-
setMediaVolume(vol);
|
|
104
|
-
(0, volume_persistance_1.persistVolume)(vol);
|
|
105
|
-
}, []);
|
|
106
|
-
(0, react_1.useImperativeHandle)(ref, () => rootRef.current);
|
|
107
|
+
(0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
|
|
107
108
|
const timelineContextValue = (0, react_1.useMemo)(() => {
|
|
108
109
|
return {
|
|
109
110
|
frame,
|
|
@@ -124,64 +125,17 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
124
125
|
setPlaying,
|
|
125
126
|
};
|
|
126
127
|
}, [setFrame]);
|
|
127
|
-
const mediaVolumeContextValue = (0, react_1.useMemo)(() => {
|
|
128
|
-
return {
|
|
129
|
-
mediaMuted,
|
|
130
|
-
mediaVolume,
|
|
131
|
-
};
|
|
132
|
-
}, [mediaMuted, mediaVolume]);
|
|
133
|
-
const setMediaVolumeContextValue = (0, react_1.useMemo)(() => {
|
|
134
|
-
return {
|
|
135
|
-
setMediaMuted,
|
|
136
|
-
setMediaVolume: setMediaVolumeAndPersist,
|
|
137
|
-
};
|
|
138
|
-
}, [setMediaVolumeAndPersist]);
|
|
139
|
-
const compositionManagerContext = (0, react_1.useMemo)(() => {
|
|
140
|
-
return {
|
|
141
|
-
compositions: [
|
|
142
|
-
{
|
|
143
|
-
component: component,
|
|
144
|
-
durationInFrames,
|
|
145
|
-
height: compositionHeight,
|
|
146
|
-
width: compositionWidth,
|
|
147
|
-
fps,
|
|
148
|
-
id: 'player-comp',
|
|
149
|
-
props: inputProps,
|
|
150
|
-
nonce: 777,
|
|
151
|
-
scale: 1,
|
|
152
|
-
folderName: null,
|
|
153
|
-
defaultProps: undefined,
|
|
154
|
-
parentFolderName: null,
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
folders: [],
|
|
158
|
-
registerFolder: () => undefined,
|
|
159
|
-
unregisterFolder: () => undefined,
|
|
160
|
-
currentComposition: 'player-comp',
|
|
161
|
-
registerComposition: () => undefined,
|
|
162
|
-
registerSequence: () => undefined,
|
|
163
|
-
sequences: [],
|
|
164
|
-
setCurrentComposition: () => undefined,
|
|
165
|
-
unregisterComposition: () => undefined,
|
|
166
|
-
unregisterSequence: () => undefined,
|
|
167
|
-
registerAsset: () => undefined,
|
|
168
|
-
unregisterAsset: () => undefined,
|
|
169
|
-
assets: [],
|
|
170
|
-
};
|
|
171
|
-
}, [
|
|
172
|
-
component,
|
|
173
|
-
durationInFrames,
|
|
174
|
-
compositionHeight,
|
|
175
|
-
compositionWidth,
|
|
176
|
-
fps,
|
|
177
|
-
inputProps,
|
|
178
|
-
]);
|
|
179
128
|
const passedInputProps = (0, react_1.useMemo)(() => {
|
|
180
129
|
return inputProps !== null && inputProps !== void 0 ? inputProps : {};
|
|
181
130
|
}, [inputProps]);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
131
|
+
if (typeof window !== 'undefined') {
|
|
132
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
133
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
134
|
+
// Inject CSS only on client, and also only after the Player has hydrated
|
|
135
|
+
remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(`.${player_css_classname_1.PLAYER_CSS_CLASSNAME}`, '#fff'));
|
|
136
|
+
}, []);
|
|
137
|
+
}
|
|
138
|
+
return ((0, jsx_runtime_1.jsx)(SharedPlayerContext_1.SharedPlayerContexts, { timelineContext: timelineContextValue, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps: inputProps, numberOfSharedAudioTags: numberOfSharedAudioTags, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(emitter_context_1.PlayerEventEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(PlayerUI_1.default, { ref: rootRef, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: passedInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean' ? clickToPlay : Boolean(controls), showVolumeControls: Boolean(showVolumeControls), doubleClickToFullscreen: Boolean(doubleClickToFullscreen), spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: playbackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), renderPoster: renderPoster, inFrame: inFrame !== null && inFrame !== void 0 ? inFrame : null, outFrame: outFrame !== null && outFrame !== void 0 ? outFrame : null, initiallyShowControls: initiallyShowControls !== null && initiallyShowControls !== void 0 ? initiallyShowControls : true, renderFullscreen: renderFullscreenButton !== null && renderFullscreenButton !== void 0 ? renderFullscreenButton : null, renderPlayPauseButton: renderPlayPauseButton !== null && renderPlayPauseButton !== void 0 ? renderPlayPauseButton : null }) }) }) }));
|
|
185
139
|
};
|
|
186
|
-
|
|
187
|
-
exports.Player = (
|
|
140
|
+
const forward = react_1.forwardRef;
|
|
141
|
+
exports.Player = forward(PlayerFn);
|
package/dist/PlayerControls.d.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import type { MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { usePlayer } from './use-player';
|
|
4
|
+
export declare type RenderPlayPauseButton = (props: {
|
|
5
|
+
playing: boolean;
|
|
6
|
+
}) => ReactNode;
|
|
7
|
+
export declare type RenderFullscreenButton = (props: {
|
|
8
|
+
isFullscreen: boolean;
|
|
9
|
+
}) => ReactNode;
|
|
10
|
+
export declare const X_SPACER = 10;
|
|
11
|
+
export declare const X_PADDING = 12;
|
|
12
|
+
declare global {
|
|
13
|
+
interface Document {
|
|
14
|
+
webkitFullscreenEnabled?: boolean;
|
|
15
|
+
webkitFullscreenElement?: Element;
|
|
16
|
+
webkitExitFullscreen?: Document['exitFullscreen'];
|
|
17
|
+
}
|
|
18
|
+
interface HTMLDivElement {
|
|
19
|
+
webkitRequestFullScreen: HTMLDivElement['requestFullscreen'];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
3
22
|
export declare const Controls: React.FC<{
|
|
4
23
|
fps: number;
|
|
5
24
|
durationInFrames: number;
|
|
@@ -11,4 +30,12 @@ export declare const Controls: React.FC<{
|
|
|
11
30
|
allowFullscreen: boolean;
|
|
12
31
|
onExitFullscreenButtonClick: MouseEventHandler<HTMLButtonElement>;
|
|
13
32
|
spaceKeyToPlayOrPause: boolean;
|
|
33
|
+
onSeekEnd: () => void;
|
|
34
|
+
onSeekStart: () => void;
|
|
35
|
+
inFrame: number | null;
|
|
36
|
+
outFrame: number | null;
|
|
37
|
+
initiallyShowControls: number | boolean;
|
|
38
|
+
playerWidth: number;
|
|
39
|
+
renderPlayPauseButton: RenderPlayPauseButton | null;
|
|
40
|
+
renderFullscreenButton: RenderFullscreenButton | null;
|
|
14
41
|
}>;
|
package/dist/PlayerControls.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Controls = void 0;
|
|
3
|
+
exports.Controls = exports.X_PADDING = exports.X_SPACER = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const remotion_1 = require("remotion");
|
|
@@ -8,7 +8,9 @@ const format_time_1 = require("./format-time");
|
|
|
8
8
|
const icons_1 = require("./icons");
|
|
9
9
|
const MediaVolumeSlider_1 = require("./MediaVolumeSlider");
|
|
10
10
|
const PlayerSeekBar_1 = require("./PlayerSeekBar");
|
|
11
|
-
const
|
|
11
|
+
const use_video_controls_resize_1 = require("./use-video-controls-resize");
|
|
12
|
+
exports.X_SPACER = 10;
|
|
13
|
+
exports.X_PADDING = 12;
|
|
12
14
|
const containerStyle = {
|
|
13
15
|
boxSizing: 'border-box',
|
|
14
16
|
position: 'absolute',
|
|
@@ -18,8 +20,8 @@ const containerStyle = {
|
|
|
18
20
|
paddingBottom: 10,
|
|
19
21
|
background: 'linear-gradient(transparent, rgba(0, 0, 0, 0.4))',
|
|
20
22
|
display: 'flex',
|
|
21
|
-
paddingRight:
|
|
22
|
-
paddingLeft:
|
|
23
|
+
paddingRight: exports.X_PADDING,
|
|
24
|
+
paddingLeft: exports.X_PADDING,
|
|
23
25
|
flexDirection: 'column',
|
|
24
26
|
transition: 'opacity 0.3s',
|
|
25
27
|
};
|
|
@@ -58,30 +60,79 @@ const flex1 = {
|
|
|
58
60
|
flex: 1,
|
|
59
61
|
};
|
|
60
62
|
const fullscreen = {};
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
fontFamily: 'sans-serif',
|
|
64
|
-
fontSize: 14,
|
|
65
|
-
};
|
|
66
|
-
const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, }) => {
|
|
63
|
+
const PlayPauseButton = ({ playing }) => playing ? (0, jsx_runtime_1.jsx)(icons_1.PauseIcon, {}) : (0, jsx_runtime_1.jsx)(icons_1.PlayIcon, {});
|
|
64
|
+
const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls, playerWidth, renderPlayPauseButton, renderFullscreenButton, }) => {
|
|
67
65
|
const playButtonRef = (0, react_1.useRef)(null);
|
|
68
66
|
const frame = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
67
|
+
const [supportsFullscreen, setSupportsFullscreen] = (0, react_1.useState)(false);
|
|
68
|
+
const { maxTimeLabelWidth, displayVerticalVolumeSlider } = (0, use_video_controls_resize_1.useVideoControlsResize)({ allowFullscreen, playerWidth });
|
|
69
|
+
const [shouldShowInitially, setInitiallyShowControls] = (0, react_1.useState)(() => {
|
|
70
|
+
if (typeof initiallyShowControls === 'boolean') {
|
|
71
|
+
return initiallyShowControls;
|
|
72
|
+
}
|
|
73
|
+
if (typeof initiallyShowControls === 'number') {
|
|
74
|
+
if (initiallyShowControls % 1 !== 0) {
|
|
75
|
+
throw new Error('initiallyShowControls must be an integer or a boolean');
|
|
76
|
+
}
|
|
77
|
+
if (Number.isNaN(initiallyShowControls)) {
|
|
78
|
+
throw new Error('initiallyShowControls must not be NaN');
|
|
79
|
+
}
|
|
80
|
+
if (!Number.isFinite(initiallyShowControls)) {
|
|
81
|
+
throw new Error('initiallyShowControls must be finite');
|
|
82
|
+
}
|
|
83
|
+
if (initiallyShowControls <= 0) {
|
|
84
|
+
throw new Error('initiallyShowControls must be a positive integer');
|
|
85
|
+
}
|
|
86
|
+
return initiallyShowControls;
|
|
87
|
+
}
|
|
88
|
+
throw new TypeError('initiallyShowControls must be a number or a boolean');
|
|
89
|
+
});
|
|
69
90
|
const containerCss = (0, react_1.useMemo)(() => {
|
|
70
91
|
// Hide if playing and mouse outside
|
|
71
|
-
const shouldShow = hovered || !player.playing;
|
|
92
|
+
const shouldShow = hovered || !player.playing || shouldShowInitially;
|
|
72
93
|
return {
|
|
73
94
|
...containerStyle,
|
|
74
95
|
opacity: Number(shouldShow),
|
|
75
96
|
};
|
|
76
|
-
}, [hovered, player.playing]);
|
|
97
|
+
}, [hovered, shouldShowInitially, player.playing]);
|
|
77
98
|
(0, react_1.useEffect)(() => {
|
|
78
99
|
if (playButtonRef.current && spaceKeyToPlayOrPause) {
|
|
79
100
|
// This switches focus to play button when player.playing flag changes
|
|
80
|
-
playButtonRef.current.focus(
|
|
101
|
+
playButtonRef.current.focus({
|
|
102
|
+
preventScroll: true,
|
|
103
|
+
});
|
|
81
104
|
}
|
|
82
105
|
}, [player.playing, spaceKeyToPlayOrPause]);
|
|
83
|
-
|
|
106
|
+
(0, react_1.useEffect)(() => {
|
|
107
|
+
var _a;
|
|
108
|
+
// Must be handled client-side to avoid SSR hydration mismatch
|
|
109
|
+
setSupportsFullscreen((_a = (typeof document !== 'undefined' &&
|
|
110
|
+
(document.fullscreenEnabled || document.webkitFullscreenEnabled))) !== null && _a !== void 0 ? _a : false);
|
|
111
|
+
}, []);
|
|
112
|
+
(0, react_1.useEffect)(() => {
|
|
113
|
+
if (shouldShowInitially === false) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const time = shouldShowInitially === true ? 2000 : shouldShowInitially;
|
|
117
|
+
const timeout = setTimeout(() => {
|
|
118
|
+
setInitiallyShowControls(false);
|
|
119
|
+
}, time);
|
|
120
|
+
return () => {
|
|
121
|
+
clearInterval(timeout);
|
|
122
|
+
};
|
|
123
|
+
}, [shouldShowInitially]);
|
|
124
|
+
const timeLabel = (0, react_1.useMemo)(() => {
|
|
125
|
+
return {
|
|
126
|
+
color: 'white',
|
|
127
|
+
fontFamily: 'sans-serif',
|
|
128
|
+
fontSize: 14,
|
|
129
|
+
maxWidth: maxTimeLabelWidth,
|
|
130
|
+
overflow: 'hidden',
|
|
131
|
+
textOverflow: 'ellipsis',
|
|
132
|
+
};
|
|
133
|
+
}, [maxTimeLabelWidth]);
|
|
134
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: containerCss, children: [(0, jsx_runtime_1.jsxs)("div", { style: controlsRow, children: [(0, jsx_runtime_1.jsxs)("div", { style: leftPartStyle, children: [(0, jsx_runtime_1.jsx)("button", { ref: playButtonRef, type: "button", style: buttonStyle, onClick: player.playing ? player.pause : player.play, "aria-label": player.playing ? 'Pause video' : 'Play video', title: player.playing ? 'Pause video' : 'Play video', children: renderPlayPauseButton === null ? ((0, jsx_runtime_1.jsx)(PlayPauseButton, { playing: player.playing })) : (renderPlayPauseButton({ playing: player.playing })) }), showVolumeControls ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsx)(MediaVolumeSlider_1.MediaVolumeSlider, { displayVerticalVolumeSlider: displayVerticalVolumeSlider })] })) : null, (0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsxs)("div", { style: timeLabel, children: [(0, format_time_1.formatTime)(frame / fps), " / ", (0, format_time_1.formatTime)(durationInFrames / fps)] }), (0, jsx_runtime_1.jsx)("div", { style: xSpacer })] }), (0, jsx_runtime_1.jsx)("div", { style: flex1 }), (0, jsx_runtime_1.jsx)("div", { style: fullscreen, children: supportsFullscreen && allowFullscreen ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "aria-label": isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', title: isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', style: buttonStyle, onClick: isFullscreen
|
|
84
135
|
? onExitFullscreenButtonClick
|
|
85
|
-
: onFullscreenButtonClick, children: (0, jsx_runtime_1.jsx)(icons_1.FullscreenIcon, {
|
|
136
|
+
: onFullscreenButtonClick, children: renderFullscreenButton === null ? ((0, jsx_runtime_1.jsx)(icons_1.FullscreenIcon, { isFullscreen: isFullscreen })) : (renderFullscreenButton({ isFullscreen })) })) : null })] }), (0, jsx_runtime_1.jsx)("div", { style: ySpacer }), (0, jsx_runtime_1.jsx)(PlayerSeekBar_1.PlayerSeekBar, { onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, durationInFrames: durationInFrames, inFrame: inFrame, outFrame: outFrame })] }));
|
|
86
137
|
};
|
|
87
138
|
exports.Controls = Controls;
|