0

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.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
hachi09
  • 21
  • 1
  • 6
  • This is React -- do NOT use document (DOM) to create element. instead used the element using the useRef() hook – NBaua Apr 22 '21 at 11:25
  • still if this is utmost required for you to manipulate the DOM, render the DOM element using 'react-dom' NPM package and then fiddle it with. – NBaua Apr 22 '21 at 11:27

0 Answers0