The videojs object does not have an addEvent method

I have video recording installed and it works to play the video, however, when I try to use the API, I encounter some problems.

For instance:

_V_("video").ready(function() { v = this v.play() } 

It works as expected, playing the video as soon as everything is downloaded.

However, tracking a click on a playback event this way:

 _V_("video").ready(function() { v = this v.addEvent('play', function() { console.log('play') }) } 

Gives me:

 Uncaught TypeError: Object [object Object] has no method 'addEvent' 

I am not sure what I am doing wrong as I follow the API docs.

+6
source share
1 answer

In Video.js 4.0 addEvent has been replaced with 'on' .

 v.on('play', fn); 
+12
source

Source: https://habr.com/ru/post/946528/


All Articles