videojs 播放的各个生命周期callback

player.on( 'durationchange',  function( e ) { window.console.log( 'videoJS: durationchange' ); });
player.on( 'ended',       function( e ) { window.console.log( 'videoJS: ended' ); });
player.on( 'error',       function( e ) { window.console.log( 'videoJS: error' ); });
player.on( 'firstplay',     function( e ) { window.console.log( 'videoJS: firstplay' ); });
player.on( 'loadedalldata',   function( e ) { window.console.log( 'videoJS: loadedalldata' ); });
player.on( 'loadeddata',    function( e ) { window.console.log( 'videoJS: loadeddata' ); });
player.on( 'loadedmetadata',  function( e ) { window.console.log( 'videoJS: loadedmetadata' ); });
player.on( 'loadstart',     function( e ) { window.console.log( 'videoJS: loadstart' ); });
player.on( 'pause',       function( e ) { window.console.log( 'videoJS: pause' ); });
player.on( 'play',        function( e ) { window.console.log( 'videoJS: play (adState: ' + player.ads.state + ')' ); });
player.on( 'seeked',      function( e ) { window.console.log( 'videoJS: seeked' ); });
player.on( 'seeking',       function( e ) { window.console.log( 'videoJS: seeking' ); });
player.on( 'waiting',       function( e ) { window.console.log( 'videoJS: waiting' ); });

player.on( 'contentplayback',   function( e ) { window.console.log( 'videoJS: contentplayback' ); });
player.on( 'ended',       function( e ) { window.console.log( 'videoJS: ended' ); });

player.on( 'ima3error',     function( e ) { window.console.log( 'videoJS/IMA3: ima3error' ); });
player.on( 'ima3-ad-error',   function( e ) { window.console.log( 'videoJS/IMA3: ima3-ad-error' ); });
player.on( 'ima3-ready',    function( e ) { window.console.log( 'videoJS/IMA3: ima3-ready' ); });

player.on( 'ads-request',     function( e ) { window.console.log( 'videoJS/Ads: ads-request' ); });
player.on( 'ads-load',    function( e ) { window.console.log( 'videoJS/Ads: ads-load' ); });
player.on( 'ads-ad-started',    function( e ) { window.console.log( 'videoJS/Ads: ads-ad-started' ); });
player.on( 'ads-ad-ended',    function( e ) { window.console.log( 'videoJS/Ads: ads-ad-ended' ); });
player.on( 'ads-first-quartile',    function( e ) { window.console.log( 'videoJS/Ads: ads-first-quartile' ); });

Note:最新的Event可以从下面的图片和URL来确认:
https://videojs.com/advanced/

遇到过的坑:
1,在firstplay的回调中设置currenttime,IE 11的情况下,有时候不起作用。

原因是:有些浏览器不触发firstplay方法

解决办法: 通过在外面定义一个变量,然后在loadeddata中进行判断

你可能感兴趣的:(videojs 播放的各个生命周期callback)