I am using plyr javascript plugin from here - https://github.com/sampotts/plyr and I need to detect that the user is watching the video. Eventually I will add code for gathering statistics using AJAX. However the code below doesn't work.
const player = new Plyr('#video1', {
controls: ['play-large', 'play', 'progress', 'current-time', 'captions', 'fullscreen', 'settings']
});
jQuery(function ($) {
if (player.playing) {
alert ("playing!!");
}
});