提交 cac55db1 编写于 作者: Q qiang

feat: innerAudioContext 实现取消事件监听方法 fixed #393

上级 86e5187c
/**
* 可以批量设置的监听事件
*/
var innerAudioContextEventNames = ['onCanplay', 'onPlay', 'onPause', 'onStop', 'onEnded', 'onTimeUpdate', 'onError', 'onWaiting', 'onSeeking', 'onSeeked']
const innerAudioContextEventNames = ['onCanplay', 'onPlay', 'onPause', 'onStop', 'onEnded', 'onTimeUpdate', 'onError', 'onWaiting', 'onSeeking', 'onSeeked']
const innerAudioContextOffEventNames = ['offCanplay', 'offPlay', 'offPause', 'offStop', 'offEnded', 'offTimeUpdate', 'offError', 'offWaiting', 'offSeeking', 'offSeeke']
/**
* 音频上下文对象
*/
......@@ -138,6 +141,17 @@ innerAudioContextEventNames.forEach((eventName) => {
}
})
// 批量设置音频上下文事件取消监听方法
innerAudioContextOffEventNames.forEach((eventName) => {
InnerAudioContext.prototype[eventName] = function (callback) {
var handle = this._events[eventName.replace('off', 'on')]
var index = handle.indexOf(callback)
if (index >= 0) {
handle.splice(index, 1)
}
}
})
/**
* 创建音频上下文
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册