Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add event listener to videojs when start to play a video?

How do I add event listener to videojs when the video is start to play? (this event should be called at the begging of the play)?

I searched on Player Events docs, but I can't find any event that tell me "now the video is start play".

like image 740
Jon Sud Avatar asked Dec 05 '19 13:12

Jon Sud


People also ask

How do I initialize a video in Javascript?

js setup methods are used to initialize a video. var myPlayer = videojs('example_video_1'); In the following example, the data-setup attribute tells the Video. js library to create a player instance when the library is ready.

How do I add an event listener to just once?

Using the once option We can pass an object as an argument to the addEventListener method and specify that the event is only handled once. This is achieved by passing the property once to the object. If we set once to true, the event will only be fired once.

Can VideoJS play audio?

Audio tracks are supported in Video. js's MSE playback engine for HLS and DASH. Safari also supports audio tracks for native playback of HLS and MP4. Other browsers do not support audio tracks for native playback including MP4, so it is not possible to work with MP4 audio tracks in Chrome or Firefox for example.


1 Answers

You can do this videojs way.

play.on('play', () => { });

enter image description here

like image 112
Shlomi Levi Avatar answered Oct 17 '22 05:10

Shlomi Levi