This commit is contained in:
yumoqing 2025-01-12 11:52:30 +08:00
parent 09b78e025f
commit 52eccca8cd

View File

@ -114,13 +114,25 @@ bricks.Video = class extends bricks.Layout {
}
}
report_ended(){
if (this.play_status != 'playok'){
returnl
}
this.play_status = 'playend';
this.dispatch('play_end',{src:this.video_body.cur_url,type:this.video_body.cur_vtype});
}
report_playok(){
if (this.play_status != ''){
return;
}
this.play_status = '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(){
if (this.play_status != ''){
return;
}
this.play_status = 'playfailed';
console.log(this.video_body.cur_url, 'play failed', this.err_cnt, 'times');
this.dispatch('play_failed', {'src':this.video_body.cur_url, type:this.video_body.cur_vtype});
}
@ -130,6 +142,7 @@ bricks.Video = class extends bricks.Layout {
src:this.video_body.cur_url,
type:this.video_body.cur_vtype
});
this.play_status = '';
}
}
set_source(url, vtype){
@ -149,21 +162,72 @@ bricks.Video = class extends bricks.Layout {
this._set_source();
}
}
set_url(url){
this.set_source(url);
}
}
bricks.Iptv = class extends bricks.VBox {
/*
{
iptv_data
iptv_data_url:
playok_url:
playfailed_url:
}
*/
constructor(opts){
super(opts);
this.user_data = iptv_data;
this.video = new bricks.Video({url:opts.iptv_data.url});
this.title_w = new bricks.Text({text:opts.iptv_data.title, wrap:false});
schedule_once(this.build_subwidgets.bind(this), 0.1);
}
async build_subwidgets(){
var jc = new bricks.HttpJson();
this.user_data = await jc.get(iptv_data_url);
this.video = new bricks.Video({url:this.iptv_data.url});
this.title_w = new bricks.Text({text:this.iptv_data.title, wrap:false});
this.add_widget(this.title_w);
this.add_widget(this.video);
this.video.bind('play_ok', this.report_play_ok.bind(this));
this.video.bind('play_failed', this.report_play_failed.bind(this));
}
async report_play_ok(){
if (this.playok_url){
var desc = {
"widgettye":"urlwidget",
"options":{
"url":this.playok_url,
"params":this.user_data
}
}
var w = widgetBuild(desc, this);
if (w){
console.log('report playok ok');
} else {
console.log('report playok failed');
}
}
}
async report_play_failed(){
if (this.playfailed_url){
var desc = {
"widgettye":"urlwidget",
"options":{
"url":this.playfailed_url,
"params":this.user_data
}
}
var w = widgetBuild(desc, this);
if (w){
console.log('report playfailed ok');
} else {
console.log('report playfailed failed');
}
}
}
setValue(data){
this.user_data = data;
this.video.set_url(data.url);
}
}
bricks.Factory.register('Video', bricks.Video);