From 09b78e025f83c830ea870f34b6d631cfb7928dde Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 12 Jan 2025 10:56:06 +0800 Subject: [PATCH 1/3] bugfix --- bricks/video.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bricks/video.js b/bricks/video.js index f9ba8c9..c1b8ee3 100644 --- a/bricks/video.js +++ b/bricks/video.js @@ -26,6 +26,7 @@ bricks.VideoBody = class extends bricks.Layout { bricks.Video = class extends bricks.Layout { /* { + title: vtype: url: fullscreen: @@ -150,4 +151,19 @@ bricks.Video = class extends bricks.Layout { } } +bricks.Iptv = class extends bricks.VBox { + /* + { + iptv_data + } + */ + 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}); + this.add_widget(this.title_w); + this.add_widget(this.video); + } +} bricks.Factory.register('Video', bricks.Video); From 52eccca8cd018da7b6432ba18168ea6bdf1d5a39 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 12 Jan 2025 11:52:30 +0800 Subject: [PATCH 2/3] bugfix --- bricks/video.js | 72 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/bricks/video.js b/bricks/video.js index c1b8ee3..a8cec15 100644 --- a/bricks/video.js +++ b/bricks/video.js @@ -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); From a2e0abb5249fc6a2d21d8d5250832a5f26c60a12 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 12 Jan 2025 22:13:54 +0800 Subject: [PATCH 3/3] bugfix --- bricks/header.tmpl | 4 +-- bricks/video.js | 77 +++++++++++++++++++++++++++++----------------- 2 files changed, 50 insertions(+), 31 deletions(-) diff --git a/bricks/header.tmpl b/bricks/header.tmpl index 167f442..48f0c53 100644 --- a/bricks/header.tmpl +++ b/bricks/header.tmpl @@ -5,22 +5,22 @@ - +--> diff --git a/bricks/video.js b/bricks/video.js index a8cec15..86dcee1 100644 --- a/bricks/video.js +++ b/bricks/video.js @@ -64,6 +64,7 @@ bricks.Video = class extends bricks.Layout { } } auto_play(){ + return; schedule_once(this._auto_play.bind(this), 0.5); } _auto_play(){ @@ -74,6 +75,10 @@ bricks.Video = class extends bricks.Layout { play(){ console.log('Video:play() called....'); this.player.play(); + // this.player.muted(false); + } + unmuted(){ + this.player.muted(false); } set_fullscreen(){ if (this.fullscreen){ @@ -101,16 +106,10 @@ bricks.Video = class extends bricks.Layout { this.player.on('ended', this.report_ended.bind(this)); this._set_source(); this.player.ready(this.set_fullscreen.bind(this)); - /* + console.log('=======', this.autoplay, '========'); if (this.autoplay){ - this.player.autoplay = true; - this.player.muted = true; - this.player.ready(this.auto_play.bind(this)); - } else { - console.log('autoplay=', this.autoplay, this.auto_play); - // this.player.ready(this.auto_play.bind(this)); + this.auto_play(); } - */ } } report_ended(){ @@ -160,6 +159,7 @@ bricks.Video = class extends bricks.Layout { this.video_body.cur_url = url; this.video_body.cur_vtype = vtype; this._set_source(); + this.play(); } } set_url(url){ @@ -180,54 +180,73 @@ bricks.Iptv = class extends bricks.VBox { schedule_once(this.build_subwidgets.bind(this), 0.1); } async build_subwidgets(){ + console.log('build_subwidgets called'); 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.deviceid = bricks.deviceid('iptv') + this.user_data = await jc.httpcall(this.iptv_data_url, { + params:{ + deviceid:this.deviceid + }, + method:'GET' + }); + console.log('this.user_data =', this.user_data); + this.video = new bricks.Video({ + autoplay:true, + url:this.user_data.url + }); + this.title_w = new bricks.Text({text:this.user_data.tv_name, 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(){ + console.log(this.user_data, 'channel playing ...', this.playok_url); if (this.playok_url){ - var desc = { - "widgettye":"urlwidget", - "options":{ - "url":this.playok_url, - "params":this.user_data - } - } - var w = widgetBuild(desc, this); - if (w){ + var ht = new bricks.HttpText(); + var resp = ht.httpcall(this.playok_url,{ + params:{ + deviceid:this.deviceid, + channelid:this.user_data.id + }, + method:"GET" + }); + if (resp != 'Error'){ console.log('report playok ok'); } else { console.log('report playok failed'); } + } else { + console.log('this.playok_url not defined', this.playok_url); } } async report_play_failed(){ + console.log(this.user_data, 'channel 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){ + var ht = new bricks.HttpText(); + var resp = ht.httpcall(this.playfailed_url,{ + params:{ + deviceid:this.deviceid, + channelid:this.user_data.id + }, + method:"GET" + }); + if (resp != 'Error'){ console.log('report playfailed ok'); } else { console.log('report playfailed failed'); } + } else { + console.log('this.playfailed_url not defined', this.playfailed_url); } } setValue(data){ this.user_data = data; + this.title_w.set_text(data.tv_name); this.video.set_url(data.url); } } bricks.Factory.register('Video', bricks.Video); +bricks.Factory.register('Iptv', bricks.Iptv);