gpt4 book ai didi

html - 类型 'captureStream' 上不存在属性 'HTMLVideoElement'

转载 作者:行者123 更新时间:2023-12-05 03:40:42 26 4
gpt4 key购买 nike

<分区>

我正在制作一个简单的项目,该项目在带有 typescript 的 React 中使用 WebRTC。

我正在关注 MDN HTMLMediaElement.captureStream() .

const vid: HTMLVideoElement | null = document.querySelector("video");
if (vid) {
vid.captureStream();
}

.
.
.

<video id="myVid"></video>

但是我得到了这个错误,

Property 'captureStream' does not exist on type 'HTMLVideoElement'.ts(2339)

我试过,

const vid: HTMLMediaElement | null = document.querySelector("video");

我做错了什么??

编辑

我试过了

const videoCont = useRef<HTMLVideoElement>(null);

var URL = window.URL || window.webkitURL
const fileURL = URL.createObjectURL(e)
if (videoCont.current) {
videoCont.current.src = fileURL;
videoCont.current.play = async () => {
const mediaStream = videoCont.current?.captureStream();
}
}

还是一样的错误,

Property 'captureStream' does not exist on type 'HTMLVideoElement'.

编辑2

我调查了 unresolved method captureStream on HTMLCanvasElement .

显然,这仍然是一项实验性功能,并非所有浏览器都支持。将不得不等待。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com