# Stream from Stream Capture API with VideoTexture gives a black panel

**URL:** <https://discourse.threejs.org/t/stream-from-stream-capture-api-with-videotexture-gives-a-black-panel/23264>\
**Category:** Questions\
**Tags:** video-texture\
**Created:** [February 8, 2021, 11:01pm UTC](https://discourse.threejs.org/t/stream-from-stream-capture-api-with-videotexture-gives-a-black-panel/23264 "2021-02-08T23:01:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asarra](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/asarra/32/16227_2.png) [@asarra](https://discourse.threejs.org/u/asarra)\
**Post date:** [February 8, 2021, 11:01pm UTC](https://discourse.threejs.org/t/stream-from-stream-capture-api-with-videotexture-gives-a-black-panel/23264/1 "2021-02-08T23:01:44Z")

</div>

For some reason I cannot replace the texture of my room model’s panel into a videostream from the stream capture API. The panel turns into a black color instead.

`<video id="video" playsinline muted autoplay style="display: none;" crossorigin="anonymous"></video>`

* * *

```
const videoElem = document.getElementById("video");
            async function startCapture() {
                try {
                    videoElem.srcObject=await navigator.mediaDevices.getDisplayMedia({video: {cursor: "motion"},audio: false}); //parameter = displayMediaOptions
                } catch(err) {
                    console.error("Error: " + err);
                }
            }
            function stopCapture() {
                videoElem.srcObject.getTracks().forEach(track => track.stop());
                videoElem.srcObject = null;
            }
            document.body.appendChild(video);
            startCapture();

```

* * *

```
                const texture = new THREE.TextureLoader().load(new THREE.VideoTexture( videoElem ));
                const renderer = new THREE.WebGLRenderer({ antialias: true });
                var loader = new THREE.GLTFLoader();
                renderer.setClearColor( 0x000000, 1 );
                renderer.setSize( window.innerWidth, window.innerHeight );

                //Imports room model
                loader.load( 'room with directional lighting.glb', function ( gltf ) {
                    room=gltf.scene;

                    //Modify plane's material (video stream)
                    if(room.children[4].name=="Monitor-Plane"){
                        room.children[4].material = new THREE.MeshBasicMaterial({map: texture});
                    }
                    scene.add(room);
                }, undefined, function ( error ) {
                    console.error( error );
                } );
```

---

<div class="post-metadata">

**Author:** ![asarra](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/asarra/32/16227_2.png) [@asarra](https://discourse.threejs.org/u/asarra)\
**Post date:** [February 9, 2021, 10:56am UTC](https://discourse.threejs.org/t/stream-from-stream-capture-api-with-videotexture-gives-a-black-panel/23264/2 "2021-02-09T10:56:31Z")

</div>

Since no one is commenting.  
I have solved it on my own by experimenting with a new plane.  
The problem was that “I don’t have to use: texture = new THREE.TextureLoader().load();”, but declare what I give into the load function as a parameter as texture.

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [February 9, 2021, 11:10am UTC](https://discourse.threejs.org/t/stream-from-stream-capture-api-with-videotexture-gives-a-black-panel/23264/3 "2021-02-09T11:10:52Z")

</div>

Yeah, instead of:

```javascript
const texture = new THREE.TextureLoader().load(new THREE.VideoTexture( videoElem ));

```

this should be sufficient:

```javascript
const texture = new THREE.VideoTexture( videoElem );

```
