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

refactor(app): BackgroundAudioManager

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