Merge branch 'main' of git.kaiyuancloud.cn:yumoqing/bricks
This commit is contained in:
commit
c50d994f3e
@ -5,22 +5,22 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="{{entire_url('/bricks/3parties/xterm.css')}}" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/js-docx-viewer/dist/css/docxviewer.min.css">
|
||||
<link href="{{entire_url('/bricks/3parties/video-js.css')}}" rel="stylesheet" />
|
||||
<link rel="stylesheet" href="{{entire_url('/bricks/css/bricks.css')}}">
|
||||
<link rel="stylesheet", href="{{entire_url('/css/myapp.css')}}">
|
||||
</head>
|
||||
<body>
|
||||
<!--
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/js-docx-viewer/dist/css/docxviewer.min.css">
|
||||
<script src="//cdn.bootcdn.net/ajax/libs/eruda/2.3.3/eruda.js"></script>
|
||||
<script>eruda.init();</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.7/dist/bundle.min.js"></script>
|
||||
<script src="https://unpkg.com/docx-js@3.2.0/lib/docx.min.js"></script>
|
||||
-->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.14.305/pdf.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mammoth/1.4.2/mammoth.browser.min.js"></script>
|
||||
-->
|
||||
<script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.5.1/files/dist/echarts.min.js"></script>
|
||||
|
||||
<script src="{{entire_url('/bricks/3parties/marked.min.js')}}"></script>
|
||||
|
115
bricks/video.js
115
bricks/video.js
@ -26,6 +26,7 @@ bricks.VideoBody = class extends bricks.Layout {
|
||||
bricks.Video = class extends bricks.Layout {
|
||||
/*
|
||||
{
|
||||
title:
|
||||
vtype:
|
||||
url:
|
||||
fullscreen:
|
||||
@ -63,6 +64,7 @@ bricks.Video = class extends bricks.Layout {
|
||||
}
|
||||
}
|
||||
auto_play(){
|
||||
return;
|
||||
schedule_once(this._auto_play.bind(this), 0.5);
|
||||
}
|
||||
_auto_play(){
|
||||
@ -73,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){
|
||||
@ -100,26 +106,32 @@ 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(){
|
||||
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});
|
||||
}
|
||||
@ -129,6 +141,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){
|
||||
@ -146,8 +159,94 @@ 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){
|
||||
this.set_source(url);
|
||||
}
|
||||
}
|
||||
|
||||
bricks.Iptv = class extends bricks.VBox {
|
||||
/*
|
||||
{
|
||||
iptv_data_url:
|
||||
playok_url:
|
||||
playfailed_url:
|
||||
}
|
||||
*/
|
||||
constructor(opts){
|
||||
super(opts);
|
||||
schedule_once(this.build_subwidgets.bind(this), 0.1);
|
||||
}
|
||||
async build_subwidgets(){
|
||||
console.log('build_subwidgets called');
|
||||
var jc = new bricks.HttpJson();
|
||||
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 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 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);
|
||||
|
Loading…
Reference in New Issue
Block a user