Search.../

togglePlay( )

Toggles playback.

Description

The togglePlay() function either pauses or plays the current playback based on its current state:

  • If the playback is paused, it plays and a play event is fired. The play event handlers set on the audio player by the onPlay( ) function are called.
  • If the playback is playing, it is paused and a pause event is fired. The pause event handlers set on the audio player by the onPause( ) function are called.

Syntax

function togglePlay(): Promise<void>

togglePlay Parameters

This function does not take any parameters.

Returns

Fulfilled - When playback has been toggled.

Return Type:

Promise<void>

Was this helpful?

Toggle playback

Copy Code
1$w("#myAudioPlayer").togglePlay();
Toggle playback and log a message when done

Copy Code
1$w("#myAudioPlayer").togglePlay()
2 .then( () => {
3 console.log("Done with toggle play");
4 } );