InnerAudioContext.offEnded

The InnerAudioContext.offEnded method allows mini program developers to remove an event listener previously registered with the InnerAudioContext.onEnded method. This stops the specified listener from monitoring the event that occurs when the audio finishes playing.

Parameters

Type

Required

Description

Function listener

No

The callback that is passed to the InnerAudioContext.onEnded method. If this parameter is not specified, all InnerAudioContext.onEnded listeners are removed.

Sample code

copy
const listener = () => {
  console.log ('on audio play ended');
};
this.innerAudioContext = my.createInnerAudioContext ();
this.innerAudioContext.src = 'https://www.sample.com/sample.mp3';
this.innerAudioContext.play();
this.innerAudioContext.play ();

this.innerAudioContext.onEnded (listener);
this.innerAudioContext.offEnded (listener);