diff --git a/examples/text.js b/examples/text.js index e69de29..6e3b9ea 100644 --- a/examples/text.js +++ b/examples/text.js @@ -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); +}); diff --git a/package-lock.json b/package-lock.json index 6e6aa1d..9fedc02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -133,9 +133,9 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "shotstack-sdk": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/shotstack-sdk/-/shotstack-sdk-0.0.3.tgz", - "integrity": "sha512-BI8Ht3ov5WqwxZ+JA31rpw4agBNPSNANrvnq6lTBsEXb0O48FbRDe7ua5x4uhGS+Slzx6DvQ4qeOyLej1IBQVA==", + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/shotstack-sdk/-/shotstack-sdk-0.0.5.tgz", + "integrity": "sha512-cbKp9lfFzfjFxfwLcwmbVVCt+niU6E9BYhd5cfu7O1NTslTnBoOj0DAnzxpuNT8L+cUsHctGvFp8jGTbbGvDfg==", "requires": { "superagent": "3.7.0" } diff --git a/package.json b/package.json index 821a5c4..38250e7 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,6 @@ "author": "Jeff Shillitto", "license": "MIT", "dependencies": { - "shotstack-sdk": "0.0.3" + "shotstack-sdk": "0.0.5" } }