Skip to content

Audio/Video Tracks

Synchronize external audio or video with the score

Methods

setTrack()

Configure an audio or video track Sets up a new audio or video track to synchronize with the score playback. This allows you to play backing tracks, reference recordings, or video alongside the score.

typescript
setTrack(parameters: ScoreTrackConfiguration): Promise<void>

Parameters:

  • parameters - ScoreTrackConfiguration
View ScoreTrackConfiguration type definition

ScoreTrackConfiguration

Configuration for audio/video track synchronization with score

Properties:

  • id: string - Unique identifier for this track configuration
  • type: ScoreTrackType - The type of media track
  • url (optional): string - URL of the media file (required for 'soundcloud' and 'audio' types)
  • mediaId (optional): string - Video/media identifier (required for 'youtube' and 'vimeo' types)
  • totalTime (optional): number - Total duration in seconds (required for 'external' type)
  • synchronizationPoints: ScoreTrackSynchronizationPoint[] - List of synchronization points between score and media

Returns: Promise<void>

Throws:

  • Error - If the track configuration is invalid

Example:

typescript
const embed = new Embed('container', config);
await embed.setTrack({
  id: 'backing-track',
  type: 'audio',
  url: 'https://example.com/track.mp3',
  synchronizationPoints: [
    { type: 'measure', measure: 0, time: 0 }
  ]
});

See also:


useTrack()

Enable a previously configured track Activates a track that was previously configured with setTrack(). Only one track can be active at a time.

typescript
useTrack(parameters: { id: string; }): Promise<void>

Parameters:

  • parameters.id - string

Returns: Promise<void>

Throws:

  • Error - If the track ID is invalid or track cannot be enabled

Examples:

typescript
// Enable a configured backing track
await embed.useTrack({ id: 'backing-track-1' });

See also:


seekTrackTo()

Seek to a position in the audio track Moves the playback position of the currently active audio/video track to a specific time. This is useful for synchronizing with score playback or jumping to specific sections.

typescript
seekTrackTo(parameters: { time: number; }): Promise<void>

Parameters:

  • parameters.time - number

Returns: Promise<void>

Throws:

  • Error - If no track is active or seeking fails

Examples:

typescript
// Seek to 30 seconds
await embed.seekTrackTo({ time: 30 });

See also:


Copyright © Tutteo Limited