This commit is contained in:
yumoqing 2025-02-03 18:07:57 +08:00
parent 359f177de6
commit 15879271ce

View File

@ -63,15 +63,32 @@ bricks.Video = class extends bricks.Layout {
}
}
}
findVideoButtonByClass(cls){
var e = this.dom_element;
return e.querySelector('.' + cls);
}
auto_play(){
return;
schedule_once(this._auto_play.bind(this), 0.5);
schedule_once(this._auto_play.bind(this), 0.8);
}
_auto_play(){
var play_btn = this.findVideoButtonByClass('vjs-big-play-button');
if (!play_btn){
console.log('vjs-big-play-button not found');
return;
}
console.log('video ready, auto_playing ....');
schedule_once(this.disable_captions.bind(this), 2);
this.hidedbtn.dispatch('click');
var clickevent = new MouseEvent('click', {
'bubbles': true, // 事件是否冒泡
'cancelable': true // 事件是否可取消
});
play_btn.dispatchEvent(clickevent);
if (this.autounmute && this.player.muted){
schedule_once(this.dispatch_mute.bind(this), 0.8);
}
}
play(){
console.log('Video:play() called....');
this.player.play();
@ -92,17 +109,19 @@ bricks.Video = class extends bricks.Layout {
}
}
dispatch_mute(){
var e = this.video_body.dom_element;
var mute_btn = e.querySelector(".vjs-mute-control");
var mute_btn = this.findVideoButtonByClass("vjs-mute-control");
if (!mute_btn){
console.log('there is not mute button found')
bricks.test_element = e;
console.log(e, 'there is not mute button found')
return;
}
var clickevent = new MouseEvent('click', {
'bubbles': true, // 事件是否冒泡
'cancelable': true // 事件是否可取消
});
mute_btn.dispatchEvent(clickEvent);
if (this.player.muted && this.autounmute){
mute_btn.dispatchEvent(clickevent);
}
}
create_player(){
@ -139,6 +158,12 @@ bricks.Video = class extends bricks.Layout {
}
this.play_status = 'playok';
console.log(this.video_body.cur_url, 'play ok');
if (this.autounmute && this.player.muted){
schedule_once(this.dispatch_mute.bind(this), 1);
console.log('mute btn clicked');
} else {
console.log(this.autounmute, 'player.muted=', this.player.muted);
}
this.dispatch('play_ok', {src:this.video_body.cur_url,type:this.video_body.cur_vtype});
}
report_error(){
@ -208,6 +233,7 @@ bricks.Iptv = class extends bricks.VBox {
console.log('this.user_data =', this.user_data);
this.video = new bricks.Video({
autoplay:true,
autounmute:this.autounmute,
url:this.user_data.url
});
this.title_w = new bricks.Text({text:this.user_data.tv_name, wrap:false});