InnerAudioContext.offStop
The InnerAudioContext.offStop
method allows mini program developers to remove an event listener previously registered with the InnerAudioContext.onStop
method. This stops the specified listener from monitoring the event that occurs when the audio is stopped.
Parameters
Type | Required | Description |
Function listener | No | The callback that is passed to the |
Sample code
copy
const listener = () => {
console.log('on audio stop');
};
this.innerAudioContext = my.createInnerAudioContext();
this.innerAudioContext.src = 'https://www.sample.com/sample.mp3';
this.innerAudioContext.play();
setTimeout(() => {
this.innerAudioContext.stop();
}, 10000);
this.innerAudioContext.onStop(listener);
setTimeout(() => {
this.innerAudioContext.offStop(listener);
this.innerAudioContext.play();
}, 10010);
setTimeout(() => {
this.innerAudioContext.stop();
}, 20000);