Skip to content

Playback Control

Control playback, volume, speed, and metronome settings

Methods

play()

Start playback Begins playing the score from the current cursor position. If playback was previously paused, it resumes from the pause position. If stopped, it starts from the beginning or the current cursor position.

typescript
play(): Promise<void>

Returns: Promise<void>

Throws:

  • Error - If no score is loaded or playback cannot start

Examples:

typescript
// Start playback
await embed.play();

See also:


pause()

Pause playback Pauses the score playback at the current position. The playback position is maintained, allowing you to resume from the same point using play().

typescript
pause(): Promise<void>

Returns: Promise<void>

Throws:

  • Error - If no score is loaded or playback cannot be paused

Examples:

typescript
// Pause playback
await embed.pause();

See also:

  • play() - Start or resume playback
  • stop() - Stop and reset playback

stop()

Stop playback Stops the score playback and resets the playback position to the beginning of the score. Unlike pause(), the playback position is not maintained.

typescript
stop(): Promise<void>

Returns: Promise<void>

Throws:

  • Error - If no score is loaded or playback cannot be stopped

Examples:

typescript
// Stop playback
await embed.stop();

See also:


mute()

Mute playback Mutes all audio output from the score playback. The playback continues but without sound. This is equivalent to setting the master volume to 0 but preserves the previous volume setting.

typescript
mute(): Promise<void>

Returns: Promise<void>

Throws:

  • Error - If muting fails

Examples:

typescript
// Mute audio
await embed.mute();

Note: There is no unmute method; use setMasterVolume to restore audio

See also:


getMasterVolume()

Get the current master volume Retrieves the current master volume level for score playback.

typescript
getMasterVolume(): Promise<number>

Returns: Promise<number>

Throws:

  • Error - If the volume cannot be retrieved

Example:

typescript
const embed = new Embed('container', config);
const masterVolume = await embed.getMasterVolume();
console.log(masterVolume);

See also:


setMasterVolume()

Set the master volume Sets the master volume level for score playback. This affects all parts proportionally based on their individual volume settings.

typescript
setMasterVolume(parameters: { volume: number; }): Promise<void>

Parameters:

  • parameters.volume - number

Returns: Promise<void>

Throws:

  • Error - If the volume value is invalid or cannot be set

Examples:

typescript
// Set volume to 50%
await embed.setMasterVolume({ volume: 50 });
typescript
// Mute audio
await embed.setMasterVolume({ volume: 0 });

See also:


getMetronomeMode()

Get the metronome mode Retrieves the current metronome setting, which controls when the metronome clicks are played during playback.

typescript
getMetronomeMode(): Promise<MetronomeMode>

Returns: Promise<MetronomeMode>

View MetronomeMode type definition

MetronomeMode

Possible values: 0, 1, 2

Throws:

  • Error - If metronome mode cannot be retrieved

Example:

typescript
const embed = new Embed('container', config);
const metronomeMode = await embed.getMetronomeMode();
console.log(metronomeMode);

See also:


setMetronomeMode()

Set the metronome mode Controls when metronome clicks are played during score playback.

typescript
setMetronomeMode(mode: MetronomeMode): Promise<void>

Parameters:

  • mode - MetronomeMode
View MetronomeMode type definition

MetronomeMode

Possible values: 0, 1, 2

Returns: Promise<void>

Throws:

  • Error - If the mode value is invalid

Examples:

typescript
// Enable continuous metronome
await embed.setMetronomeMode(1);
typescript
// Use count-in only
await embed.setMetronomeMode(0);

See also:


getPlaybackSpeed()

Get the playback speed Retrieves the current playback speed multiplier. Normal speed is 1.0.

typescript
getPlaybackSpeed(): Promise<number>

Returns: Promise<number>

Throws:

  • Error - If speed cannot be retrieved

Example:

typescript
const embed = new Embed('container', config);
const playbackSpeed = await embed.getPlaybackSpeed();
console.log(playbackSpeed);

See also:


setPlaybackSpeed()

Set the playback speed Adjusts the playback speed without affecting pitch. Useful for practice at slower or faster tempos.

typescript
setPlaybackSpeed(speed: number): Promise<void>

Parameters:

  • speed - number

Returns: Promise<void>

Throws:

  • Error - If speed is outside valid range

Examples:

typescript
// Slow down for practice
await embed.setPlaybackSpeed(0.5);
typescript
// Return to normal speed
await embed.setPlaybackSpeed(1.0);

See also:


Copyright © Tutteo Limited