提交 2e759719 编写于 作者: D DCloud_LXH

fix(App): createInnerAudioContext

上级 b1fffbc9
import { extend } from '@vue/shared' import { extend, capitalize } from '@vue/shared'
import { import {
API_CREATE_INNER_AUDIO_CONTEXT, API_CREATE_INNER_AUDIO_CONTEXT,
defineSyncApi, defineSyncApi,
...@@ -194,7 +194,7 @@ const onAudioStateChange = ({ ...@@ -194,7 +194,7 @@ const onAudioStateChange = ({
audio.__timing = setInterval(() => { audio.__timing = setInterval(() => {
const currentTime = audio.currentTime const currentTime = audio.currentTime
if (currentTime !== oldCurrentTime) { if (currentTime !== oldCurrentTime) {
emit(audio, 'timeupdate' as any) emit(audio, 'timeUpdate' as any)
} }
}, 200) }, 200)
} else if (state === 'pause' || state === 'stop' || state === 'error') { } else if (state === 'pause' || state === 'stop' || state === 'error') {
...@@ -294,7 +294,9 @@ class InnerAudioContext implements UniApp.InnerAudioContext { ...@@ -294,7 +294,9 @@ class InnerAudioContext implements UniApp.InnerAudioContext {
/** /**
* 事件监听 * 事件监听
*/ */
_callbacks: Partial<Record<InnerAudioContextEvent, Array<Function>>> _callbacks: Partial<
Record<InnerAudioContextEvent, Array<Function | undefined>>
>
/** /**
* *
* @param id 当前Audio示例id * @param id 当前Audio示例id
...@@ -432,9 +434,7 @@ function emit( ...@@ -432,9 +434,7 @@ function emit(
errMsg?: string, errMsg?: string,
errCode?: unknown errCode?: unknown
) { ) {
const name = `on${ const name = `on${capitalize(state)}` as InnerAudioContextEvent
state[0].toUpperCase() + state.substr(1)
}` as InnerAudioContextEvent
audio._callbacks[name]!.forEach((callback) => { audio._callbacks[name]!.forEach((callback) => {
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback( callback(
......
...@@ -21,6 +21,8 @@ export * from './media/saveVideoToPhotosAlbum' ...@@ -21,6 +21,8 @@ export * from './media/saveVideoToPhotosAlbum'
export * from './media/saveImageToPhotosAlbum' export * from './media/saveImageToPhotosAlbum'
export * from './media/compressImage' export * from './media/compressImage'
export * from './media/compressVideo' export * from './media/compressVideo'
export * from './media/chooseImage'
export * from './media/chooseVideo'
export * from './keyboard/keyboard' export * from './keyboard/keyboard'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册