与seek同步多个HTML5音轨 [英] Sync multiple HTML5 audio tracks with seek

查看:93
本文介绍了与seek同步多个HTML5音轨的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试同时播放多个音频文件,并使它们保持同步.但是,如果我通过暂停和设置currentTime在歌曲中向前搜索,则音频将变得不同步. currentTime属性都相等,但是声音完全不同步.

I'm trying to play multiple audio files at the same time, and keep them all in sync. However, if I seek forward in the song by pausing and setting the currentTime, the audio becomes out of sync. The currentTime properties are all equal, yet the sound is drastically out of sync.

我也尝试过在所有轨道上使用MediaController,这也不起作用.

I have also tried using a MediaController on all the tracks, which also didn't work.

有人知道搜索后如何使多个音轨保持同步吗?

Anyone know how to keep multiple tracks in sync after a seek?

推荐答案

如果您尝试使用元素进行同步,则将永远无法设法使其同步.该API并非旨在处理精确的计时.精确同步音频缓冲区的最佳方法是使用Web Audio API(

If you're trying to use elements to synchronize, you'll never quite manage to get them to sync. The api just isn't designed to handle precise timing. The best way to precisely sync audio buffers is to use the Web Audio API (https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html); you can then precisely schedule start() calls on multiple audio buffers at the same time, and they will be locked in step.

依靠流传输并期望同步是令人失望的秘诀. :)

Relying on streaming and expecting synchronization is a recipe for disappointment. :)

这篇关于与seek同步多个HTML5音轨的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆