dcloudio / dcloudio/uni-app

销毁 innerAudioContext 会导致 onTimeUpdate 无限触发

Open
#5,994 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
41.6k
Forks
3.7k
Avg merge
7h 6m
Merged PRs (30d)
6

Description

**问题描述**
创建一个innerAudioContext,播放一个在线URL,会偶现触发2次onplay回调,调用destroy方法销毁,会无限触发onTimeUpdate 回调

**复现步骤**

let innerAudioContext

const onTimeUpdate = () => {
console.log("onTimeUpdate")
}
// 播放
const playRecord = (audioUrl) => {

innerAudioContext = uni.createInnerAudioContext()
innerAudioContext.onPlay(() => {
console.log(JSON.stringify(innerAudioContext))
})
innerAudioContext.onTimeUpdate(onTimeUpdate)

innerAudioContext.src = audioUrl
innerAudioContext.play()
}

// 停止
const stopPlay = () => {
if (innerAudioContext) {
innerAudioContext.stop()
}
}
// 销毁
const destroyPlayer = () => {
if (innerAudioContext) {
innerAudioContext.destroy()
}
}

**预期结果**
destroy后不会触发onTimeUpdate回调

**实际结果**
destroy后会一直触发onTimeUpdate回调

**系统信息:**
- 发行平台: [如 微信小程序、H5平台、5+ App等]
- 操作系统 Android
- HBuilderX版本 5.0.7
- uni-app版本 HBuilderX 新建uniapp 默认模版 vue3项目
- 设备信息 RedMi Note8

**补充信息**
根据搜索,发现有修复过定时器泄露的问题,但是实际新建新项目未修复这个问题
https://github.com/dcloudio/uni-app/commit/96cdb92a84b87e65ebc4d75541e5f798a21133af
是否是代码未在5.0.7发布?
另外主要原因是play回调多次出发,这个原因是否一直未修复?
已经下载最新版本的HBuilderX,新建了一个全新的项目,使用上面的代码仍然会有这个问题,看起来定时器仍然被创建了多次

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.