# Detect when a video has started playing

**URL:** <https://forum.babylonjs.com/t/detect-when-a-video-has-started-playing/13288>\
**Category:** Questions\
**Created:** [August 11, 2020, 1:00pm UTC](https://forum.babylonjs.com/t/detect-when-a-video-has-started-playing/13288 "2020-08-11T13:00:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![saifshk17](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/saifshk17/32/1418_2.png) [@saifshk17](https://forum.babylonjs.com/u/saifshk17)\
**Post date:** [August 11, 2020, 1:00pm UTC](https://forum.babylonjs.com/t/detect-when-a-video-has-started-playing/13288/1 "2020-08-11T13:00:31Z")

</div>

Hi,

I am looking for a way to detect if a video has started playing. Most of the videos load up faster in localhost but not in a different server. Also the size of the video matters alot. So in Babylon is there a way to detect when a video has been finally loaded and has started playing? onPointerUp function works only on localhost, the video automatically starts playing on a different server. So I am not sure where the play function gets called.

```
var myPlane_1 = BABYLON.MeshBuilder.CreatePlane("myPlane_1", {
            width: 520,
            height: 350
        }, scene);
        myPlane_1.position.x = 770;
        myPlane_1.position.y = 150;
        myPlane_1.position.z = -1258;

        myPlane_1.rotation.x = -0.02;
        myPlane_1.rotation.y = 91.1;

        var mat_1 = new BABYLON.StandardMaterial("mat_1", scene);
        myPlane_1.material = mat_1;
        var videoTexture_1 = new BABYLON.VideoTexture("video_1", "videos/One.mp4", scene, false, false); //Loading Video Here
        videoTexture_1.level = 1;
        mat_1.diffuseTexture = videoTexture_1;
        myPlane_1.material = mat_1;

        scene.onPointerUp = function() {
        videoTexture_1.video.play(); //Playing video here
        console.log("Video is playing");}
```

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [August 11, 2020, 1:29pm UTC](https://forum.babylonjs.com/t/detect-when-a-video-has-started-playing/13288/2 "2020-08-11T13:29:02Z")

</div>

As we are using HTML5 video in the video texture, you can use any of the HTML5 Media Events directly on the video element. The events can be found here:

> **[Media events](https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events)**
>
> Various events are sent when handling media that are embedded in HTML documents using the audio and video elements; this section lists them and provides some helpful information about using them.

---

<div class="post-metadata">

**Author:** ![saifshk17](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/saifshk17/32/1418_2.png) [@saifshk17](https://forum.babylonjs.com/u/saifshk17)\
**Post date:** [August 11, 2020, 1:31pm UTC](https://forum.babylonjs.com/t/detect-when-a-video-has-started-playing/13288/3 "2020-08-11T13:31:47Z")

</div>

No I am using the example from Babylonjs of how to add video texture to a plane and play the video.  
[https://www.babylonjs-playground.com/#CHQ4T#1](https://www.babylonjs-playground.com/#CHQ4T#1)

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [August 11, 2020, 1:36pm UTC](https://forum.babylonjs.com/t/detect-when-a-video-has-started-playing/13288/4 "2020-08-11T13:36:05Z")

</div>

`videoTexture.video` is a video html element. You can add event listeners (just don’t forgot to remove them before disposing the scene).

Something like this:

[https://www.babylonjs-playground.com/#CHQ4T#240](https://www.babylonjs-playground.com/#CHQ4T#240)

---

<div class="post-metadata">

**Author:** ![saifshk17](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/saifshk17/32/1418_2.png) [@saifshk17](https://forum.babylonjs.com/u/saifshk17)\
**Post date:** [August 11, 2020, 1:46pm UTC](https://forum.babylonjs.com/t/detect-when-a-video-has-started-playing/13288/5 "2020-08-11T13:46:50Z")

</div>

Thanks alot. Never knew these functions can be linked to HTML5. Works like charm.
