Search.../

onEnded( )

Adds an event handler that runs when playback has ended.

Description

An audio track ends when playback reaches the duration of the audio.

If the audio track is set to play in a loop, this event handler is never triggered.

Syntax

function onEnded(handler: EventHandler): AudioPlayer
handler: function EventHandler(event: Event): void

onEnded Parameters

NAME
TYPE
DESCRIPTION
handler

The name of the function or the function expression to run when the audio track has ended.

Returns

The audio player that triggered the event.

Return Type:

EventHandler Parameters

NAME
TYPE
DESCRIPTION
event

The event that occurred.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

Get the ID of the audio player whose audio track has ended

Copy Code
1$w("#myAudioPlayer").onEnded( (event) => {
2 let targetId = event.target.id; // "myAudioPlayer"
3});