Core Methods
Essential methods for embed initialization and configuration
Methods
ready()
Wait for the embed to be ready Returns a promise that resolves when the embed iframe has fully loaded and communication with the Flat embed has been established. This method is automatically called by all other embed methods, so you typically don't need to call it directly. However, it can be useful when you want to know exactly when the embed is ready without performing any other action.
ready(): Promise<void>
Returns: Promise<void>
Examples:
// Explicitly wait for embed to be ready
const embed = new Embed('container', {
score: '56ae21579a127715a02901a6'
});
await embed.ready();
console.log('Embed is now ready!');
Note: All embed methods automatically call ready() internally, so explicit calls are optional
getEmbedConfig()
Get the embed configuration Retrieves the complete configuration object for the embed, including display settings, permissions, editor configuration, and enabled features.
getEmbedConfig(): Promise<Record<string, unknown>>
Returns: Promise<Record<string, unknown>>
Throws:
Error
- If the configuration cannot be retrieved
Examples:
// Get current embed configuration
const config = await embed.getEmbedConfig();
console.log(`Mode: ${config.mode}`);
console.log(`Controls enabled: ${config.controlsPlay}`);
setEditorConfig()
Set the editor configuration Updates the editor configuration for the embed. These settings control various aspects of the editor interface and behavior. The configuration is applied when the next score is loaded.
setEditorConfig(editor: Record<string, unknown>): Promise<void>
Parameters:
editor
-Record<string, unknown>
Returns: Promise<void>
Throws:
Error
- If the configuration is invalid
Example:
const embed = new Embed('container', config);
await embed.setEditorConfig('value');
Note: This configuration persists across score loads until changed