InnerAudioContext.offError

The InnerAudioContext.offError method allows mini program developers to remove an event listener previously registered with the InnerAudioContext.onError method. This stops the specified listener from monitoring the event that occurs when an error occurs during playback.

Parameters

Type

Required

Description

Function listener

No

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

Sample code

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

this.innerAudioContext.onError(listener);
this.innerAudioContext.offError(listener);