princ09
princ09

Reputation: 140

How to call captureStream method of HTMLVideoElement in React

I am trying to generate video stream to pass it to navigator.getUserMedia call back function. basically trying to mock getUserMedia for react test. For Above i am creating video element , setting it src and then calling captureStream() for stream.

see code below

const video = document.createElement('video');
video.autoplay = true
video.loop = true
video.src = 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
video.load()
video.play()
const stream = video.captureStream();

this code working in js file , i am getting my stream but in react project, its throws TypeError :captureStram() not a function.

Edit: I tried using ref but still it's not working.

Upvotes: 0

Views: 346

Answers (0)

Related Questions