提交 291323d6 编写于 作者: fxy060608's avatar fxy060608

refactor(app): BackgroundAudioManager

上级 36229ff4
import { extend, capitalize } from '@vue/shared'
import { extend, capitalize, isFunction } from '@vue/shared'
import {
defineSyncApi,
API_GET_BACKGROUND_AUDIO_MANAGER,
......@@ -157,13 +157,13 @@ function initMusic() {
errCode: err.code,
})
})
// @ts-ignore
// @ts-expect-error
audio.addEventListener('prev', () => {
onBackgroundAudioPrev()
onBackgroundAudioStateChange({ state: 'prev' })
})
// @ts-ignore
// @ts-expect-error
audio.addEventListener('next', () => {
onBackgroundAudioNext()
onBackgroundAudioStateChange({ state: 'next' })
})
}
......@@ -290,7 +290,7 @@ function onBackgroundAudioStateChange({
dataUrl?: string
}) {
callbacks[state].forEach((callback) => {
if (typeof callback === 'function') {
if (isFunction(callback)) {
callback(
state === 'error'
? {
......@@ -303,22 +303,6 @@ function onBackgroundAudioStateChange({
})
}
function onBackgroundAudioPrev() {
callbacks['prev'].forEach((callback) => {
if (typeof callback === 'function') {
callback({})
}
})
}
function onBackgroundAudioNext() {
callbacks['next'].forEach((callback) => {
if (typeof callback === 'function') {
callback({})
}
})
}
const onInitBackgroundAudioManager = /*#__PURE__*/ once(() => {
eventNames.forEach((item) => {
BackgroundAudioManager.prototype[`on${capitalize(item)}` as onEventNames] =
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册