分片播放时支持wav

This commit is contained in:
2023-10-04 12:23:58 +08:00
parent 5c07fbabcc
commit ba7eb1ff1a
2 changed files with 4 additions and 1 deletions

View File

@@ -145,7 +145,8 @@ export default class MusicList {
this.audio.src = URL.createObjectURL(mediaSource)
if (!item.arrayBufferChunks) item.arrayBufferChunks = []
mediaSource.addEventListener('sourceopen', async () => {
const sourceBuffer = mediaSource.addSourceBuffer(item.type)
const type = item.type === 'audio/wav' ? 'audio/wav; codecs=1' : item.type
const sourceBuffer = mediaSource.addSourceBuffer(type)
const arrayBufferLoader = async (index = 0) => {
console.log('开始加载====================================')
// 按照数据长度计算出分片应有数量, 如果数量不到且没有停止加载则一直读取