This commit is contained in:
yumoqing 2024-03-16 12:20:23 +08:00
parent b5b96efb10
commit a8be08e678

View File

@ -2,6 +2,10 @@ var bricks = window.bricks || {};
/*
we use videojs for video play
https://videojs.com
event: play_end video play finished
play_failed video play failed
play_ok video start to play
*/
bricks.VideoBody = class extends bricks.Layout {
constructor(opts){
@ -60,6 +64,8 @@ bricks.Video = class extends bricks.Layout {
this.hidedbtn.dispatch('click');
schedule_once(this.disable_captions.bind(this), 2);
this.player.on('error',this.report_error.bind(this));
this.player.on('play', this.report_playok.bind(this));
this.player.on('ended', this.report_ended.bind(this));
}
play(){
this.player.play();
@ -73,8 +79,11 @@ bricks.Video = class extends bricks.Layout {
this.player.ready(this.auto_play.bind(this));
this._set_source();
}
report_played(){
report_ended(){
this.dispatch('play_end',{src:this.video_body.cur_url,type:this.video_body.cur_vtype});
report_playok(){
console.log(this.video_body.cur_url, 'play ok');
this.dispatch('play_ok', {src:this.video_body.cur_url,type:this.video_body.cur_vtype});
}
report_error(){
console.log(this.video_body.cur_url, 'play failed', this.err_cnt, 'times');