Hi @dusk,
Here is a response to your questions.
1. How do I add a media to a Shotstack instance already in use?
Currently, the Shotstack.load()
method reloads the whole project, which resets everything.
You can manipulate the Edit
object directly and then use the shotstack.load()
method to update the Studio without losing all existing data.
To add media to an instance without reloading, follow these steps:
-
Use the Edit object (window.shotstack.edit
) to access and modify the project currently in the Studio.
-
Add a new clip (with the new media) to your Edit JSON object.
-
Update the Studio by reloading this updated Edit JSON object.
Here’s how to do it:
const currentEdit = window.shotstack.edit; // Get the current Edit JSON object
// Add a new media clip to the Edit JSON
const newClip = {
type: 'video', // The type of media (video, image, etc.)
src: 'https://your-media-url.com/media.mp4', // The URL of the media
start: 0, // The start time of the clip
length: 10 // The duration of the clip
};
currentEdit.tracks[0].clips.push(newClip); // Add the new clip to the first track
// Reload the Studio with the updated Edit JSON object
window.shotstack.load('studio', currentEdit);
This script uses the Edit object to add a new clip and reloads the Studio with the updated project.
2. Getting the JSON Output of What Has Been Created in the Studio
To get the JSON of what’s currently in the Studio, use the Edit object or listen for the update
event:
- Using the Edit object:
const currentProject = window.shotstack.edit;
console.log(currentProject); // This logs the current JSON project
2. Using the update
event listener:
This triggers every time the project is updated in the Studio (e.g., when a clip is added or edited):
window.shotstack.on('update', (data) => {
console.log('Project updated:', data); // JSON of the updated project
});
3. What are all the SDK commands not covered in the documentation?
Currently, the documented commands are the only ones available.
However, we are continuously improving the SDK and will update the documentation as new features and commands are released.