From ba7eb1ff1a08a1f707da16b33a1a4c99fa9f6a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=89?= Date: Wed, 4 Oct 2023 12:23:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=89=87=E6=92=AD=E6=94=BE=E6=97=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81wav?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ public/music.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fa5654..2d0af68 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ webrtc 实现的 p2p 信道 - [x] 使用单独的状态标识音乐是否缓存 - [x] 取消本地存储时不直接移除列表 - [x] 分片下载过程与播放控制分离 + - [x] 分片播放时支持wav + - [ ] 分片播放时支持flac - [ ] 取消本地存储时检查是否移除(其它成员可能有同一曲) - [ ] 成员列表刷新时播放被重置BUG - [ ] 集群分发 diff --git a/public/music.js b/public/music.js index eb9ad62..0eff901 100644 --- a/public/music.js +++ b/public/music.js @@ -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('开始加载====================================') // 按照数据长度计算出分片应有数量, 如果数量不到且没有停止加载则一直读取