InnerAudioContext.onStop
The InnerAudioContext.onStop
method allows mini program developers to register a callback that is executed when the audio is stopped.
Parameters
Type | Required | Description |
Function listener | Yes | The callback to be executed when the audio is stopped. |
Sample code
copy
this.innerAudioContext = my.createInnerAudioContext();
this.innerAudioContext.src = 'https://www.sample.com/sample.mp3';
this.innerAudioContext.play();
setTimeout(() => {
this.innerAudioContext.stop();
}, 5000);
this.innerAudioContext.onStop(() => {
console.log('on audio stop');
});