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('开始加载====================================') // 按照数据长度计算出分片应有数量, 如果数量不到且没有停止加载则一直读取