Skip to content

Commit

Permalink
Add text example
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffski committed Jul 27, 2019
1 parent 93c89a1 commit 5971688
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 4 deletions.
70 changes: 70 additions & 0 deletions examples/text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const Shotstack = require('shotstack-sdk');

const defaultClient = Shotstack.ApiClient.instance;
const DeveloperKey = defaultClient.authentications['DeveloperKey'];
const api = new Shotstack.DefaultApi()
const id = process.argv[2];

let apiUrl = 'https://api.shotstack.io/stage';

if (!process.env.SHOTSTACK_KEY) {
console.log('API Key is required. Set using: export SHOTSTACK_KEY=your_key_here');
process.exit(1);
}

if (process.env.SHOTSTACK_HOST) {
apiUrl = process.env.SHOTSTACK_HOST;
}

defaultClient.basePath = apiUrl;
DeveloperKey.apiKey = process.env.SHOTSTACK_KEY;

let soundtrack = new Shotstack.Soundtrack;
soundtrack
.setSrc('https://s3-ap-southeast-2.amazonaws.com/shotstack-assets/music/disco.mp3')
.setEffect('fadeInFadeOut');

let titleAsset = new Shotstack.TitleAsset;
titleAsset
.setStyle('minimal')
.setText('Hello World');

let title = new Shotstack.Clip;
title
.setAsset(titleAsset)
.setStart(0)
.setLength(5)
.setEffect('zoomIn');

let track = new Shotstack.Track;
track
.setClips([title]);

let timeline = new Shotstack.Timeline;
timeline
.setBackground('#000000')
.setSoundtrack(soundtrack)
.setTracks([track]);

let output = new Shotstack.Output;
output
.setFormat('mp4')
.setResolution('sd');

let edit = new Shotstack.Edit;
edit
.setTimeline(timeline)
.setOutput(output);

api.postRender(edit).then((data) => {
let message = data.response.message;
let id = data.response.id

console.log(message + '\n');
console.log('>> Now check the progress of your render by running:');
console.log('>> node examples/status.js ' + id);

}, (error) => {
console.error('Request failed: ', error);
process.exit(1);
});
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "Jeff Shillitto",
"license": "MIT",
"dependencies": {
"shotstack-sdk": "0.0.3"
"shotstack-sdk": "0.0.5"
}
}

0 comments on commit 5971688

Please sign in to comment.