Skip to content

Commit 4fb8e30

Browse files
Initial commit
0 parents  commit 4fb8e30

15 files changed

+1001
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
.idea

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 120,
3+
"trailingComma": "all",
4+
"tabWidth": 2,
5+
"semi": true,
6+
"singleQuote": true
7+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Creatomate
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Creatomate Preview SDK
2+
3+
The [Preview SDK](https://creatomate.com/javascript-video-sdk) lets you display video and image previews in your web app prior to creating a final MP4, GIF, JPEG or PNG through the API. This is useful when developing a web-based editing or customizer tool, and want to show a real-time rendering in the browser.
4+
5+
This package is for browser-based apps, and it works with any framework such as React, Angular, Vue, as well as plain Javascript. For creating videos and images using Node.js, refer to the `creatomate` library instead, a different NPM package that [can be found here](https://www.npmjs.com/package/creatomate).
6+
7+
[Creatomate](https://creatomate.com) is a media generation API for editing and rendering videos and images using code. The platform uses templates and JSON for generating **MP4**, **GIF**, **JPEG** or **PNG** files. All processing is handled by Creatomate's cloud infrastructure, so you do not need to maintain your own servers.
8+
9+
## Usage
10+
11+
### Installation
12+
13+
Install the package using the following command:
14+
15+
```bash
16+
npm install @creatomate/preview
17+
```
18+
19+
You can now load a video template (or [JSON](https://creatomate.com/docs/json/introduction)) as follows:
20+
21+
```javascript
22+
import { Preview } from '@creatomate/preview';
23+
24+
// The following assumes that you have a HTML element like this: <div id="container"></div>
25+
const containerElement = document.getElementById('container');
26+
27+
// Initialize a preview to be spawned within the container
28+
const preview = new Preview(containerElement, 'player', 'YOUR_VIDEO_PLAYER_TOKEN');
29+
30+
// Once the SDK is ready, load a template from the project
31+
preview.onReady = async () => {
32+
await preview.loadTemplate('YOUR_TEMPLATE_ID');
33+
34+
// You can also load a video from JSON:
35+
// await preview.setSource({ /* Your JSON here */ });
36+
};
37+
```
38+
39+
Check out the demo code provided below for a more comprehensive example.
40+
41+
### Demo
42+
43+
See the Preview SDK in action here: [Video Preview Demo](https://github.com/Creatomate/video-preview-demo)
44+
45+
## Issues & Comments
46+
47+
Feel free to contact us if you encounter any issues with the library or Creatomate API at [[email protected]](mailto:[email protected]).
48+
49+
## License
50+
51+
The Creatomate Preview SDK is licensed under the MIT license. Please refer to the [LICENSE](https://github.com/Creatomate/creatomate-node/blob/main/LICENSE) for more information.

package-lock.json

Lines changed: 238 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@creatomate/preview",
3+
"version": "1.0.0",
4+
"description": "Render video and image previews in your web app prior to creating a final MP4, GIF, JPEG or PNG through the API.",
5+
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
7+
"scripts": {
8+
"build": "tsc",
9+
"dev": "tsc --watch",
10+
"prepack": "npm run build"
11+
},
12+
"publishConfig": {
13+
"access": "public"
14+
},
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/creatomate/creatomate-preview.git"
18+
},
19+
"keywords": [],
20+
"author": "Creatomate",
21+
"license": "MIT",
22+
"homepage": "https://creatomate.com/javascript-video-sdk",
23+
"devDependencies": {
24+
"@types/uuid": "^9.0.0",
25+
"prettier": "^2.7.1",
26+
"ts-node": "^10.9.1",
27+
"typescript": "^4.8.4"
28+
},
29+
"dependencies": {
30+
"uuid": "^9.0.0"
31+
}
32+
}

src/AudioState.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export interface AudioState {
2+
/**
3+
* Audio element property. The total length of the media file used in the element.
4+
*/
5+
mediaDuration?: number;
6+
}

src/CompositionState.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ElementState } from './ElementState';
2+
3+
export interface CompositionState {
4+
/**
5+
* Composition element property. The elements in the composition.
6+
*/
7+
elements?: ElementState[];
8+
}

0 commit comments

Comments
 (0)