niklasvh / html2canvas

Screenshots with JavaScript
https://html2canvas.hertzen.com/
MIT License
30.11k stars 4.75k forks source link

Videos start playing sound during capture #3078

Open jonathanrstern opened 1 year ago

jonathanrstern commented 1 year ago

I think html2canvas is scanning the whole DOM and reading the video data, which causes them to start playing aloud.

I need it to skip the video elements, as (1) they should not be playing sound, and (2) this is hurting performance, especially on mobile.

I’ve tried ignoreElements, but I don’t think that’s the right solution. It’s still scanning the whole DOM. Is there anything else I can do?

jonathanrstern commented 1 year ago

Just following up!

Nokic233 commented 2 months ago

I think html2canvas is scanning the whole DOM and reading the video data, which causes them to start playing aloud.我认为 html2canvas 正在扫描整个 DOM 并读取视频数据,这导致它们开始大声播放。

I need it to skip the video elements, as (1) they should not be playing sound, and (2) this is hurting performance, especially on mobile.我需要它跳过视频元素,因为(1)它们不应该播放声音,(2)这会损害性能,尤其是在移动设备上。

I’ve tried ignoreElements, but I don’t think that’s the right solution. It’s still scanning the whole DOM. Is there anything else I can do?我尝试过ignoreElements,但我认为这不是正确的解决方案。它仍在扫描整个 DOM。我还有什么可以做的吗?

Although it has been a long time, I hope it can help you! data-html2canvas-ignore="true"

<audio
    data-html2canvas-ignore="true"
    src="XXXXXXX"
    autoplay
    loop
></audio>