Skip to content

Instantly share code, notes, and snippets.

@khandar-william
Last active August 1, 2019 10:00
Show Gist options
  • Save khandar-william/097616726963e55008dd894eba5d990e to your computer and use it in GitHub Desktop.
Save khandar-william/097616726963e55008dd894eba5d990e to your computer and use it in GitHub Desktop.
var EVENTS = [
// source: https://www.w3.org/TR/html5/semantics-embedded-content.html#media-elements-event-summary
'loadstart', 'progress', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'loadedmetadata', 'loadeddata', 'canplay', 'canplaythrough', 'playing', 'waiting', 'seeking', 'seeked', 'ended', 'durationchange', 'timeupdate', 'play', 'pause', 'ratechange', 'resize', 'volumechange',
// source: https://github.com/videojs/video.js/search?q=fires&unscoped_q=fires
'beforemodalopen', 'modalopen', 'beforemodalclose', 'addtrack', 'modechange', 'change', 'selectedchange', 'enabledchange', 'close', 'beforepluginsetup', 'pluginsetup', 'dispose', 'removetrack', 'sourceset', 'load', 'slideractive', 'sliderinactive', 'statechanged', 'playerresize', 'ready',
// source: https://support.brightcove.com/advertising-ima3-plugin
'adstart', 'adend', 'readyforpreroll', 'ima3-ready', 'ima3error', 'ima3-ad-error', 'ads-request', 'ads-load', 'ads-ad-started', 'ads-ad-ended', 'ads-pause', 'ads-play', 'ads-ad-skipped', 'ads-ad-skipped', 'ads-midpoint', 'ads-third-quartile', 'ads-click', 'ads-volumechange', 'ads-pod-started', 'ads-pod-ended', 'ads-allpods-completed', 'ima3-ad-error', 'ima3-ads-manager-loaded', 'ima3-all-ads-completed', 'ima3-click', 'ima3-complete', 'ima3-content-pause-requested', 'ima3-first-quartile', 'ima3-hardtimeout', 'ima3-loaded', 'ima3-midpoint', 'ima3-paused', 'ima3-ready', 'ima3-resumed', 'ima3-started', 'ima3-third-quartile', 'ima3-volume-changed'
];
// for myPlayer
var logThis = function(myPlayer, msg, id) {
myPlayer.on(EVENTS, function(e) {
console.log(msg + ' Event [' + id + '] ' + e.type + ' is invoked');
});
};
// usage: logThis(myPlayer, 'for honor', 1);
mp = videojs('player__video-element');
logThis(mp, '', '');
// for <video>
var logThis = function(obj, msg, id) {
EVENTS.forEach(
function (eventName) {
obj.addEventListener(eventName, function(e) {
console.log(msg + ' Event [' + id + '] ' + eventName + ' is invoked');
});
}
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment