This commit is contained in:
yumoqing 2024-08-23 17:29:16 +08:00
parent 224afacc2c
commit d49704f764
2 changed files with 32 additions and 2 deletions

BIN
bricks/.DS_Store vendored

Binary file not shown.

View File

@ -32,8 +32,9 @@ bricks.RTCClient = class extends bricks.VBox {
super(opts);
this.build_head();
this.videobox = new bricks.ResponsableBox({css:'filler'});
this.localVideo = new bricks.VideoBox({css:'filler'});
this.remoteVideo = new bricks.VideoBox({css:'filler'});
this.videobox.set_style('position', 'relative');
this.localVideo = new bricks.VideoBox({width:'100%',height:'100%'});
this.remoteVideo = new bricks.VideoBox({width:'25%', 'height':'25%'});
this.videobox.add_widget(this.localVideo);
this.videobox.add_widget(this.remoteVideo);
this.add_widget(this.videobox);
@ -41,6 +42,26 @@ bricks.RTCClient = class extends bricks.VBox {
this.onlineList= [];
this.init_websocket();
}
videosize_switch(){
if(this.local_small){
this.local_small = false;
this.localVideo.set_style('width','100%');
this.localVideo.set_style('height','100%');
this.localVodeo.set_style('zIndex', 0);
this.remoteVideo.set_style('width','25%');
this.remoteVideo.set_style('height','25%');
this.remoteVodeo.set_style('zIndex', 2);
} else {
this.local_small = true;
this.remoteVideo.set_style('width','100%');
this.remoteVideo.set_style('height','100%');
this.remoteVodeo.set_style('zIndex', 0);
this.localVideo.set_style('width','25%');
this.localVideo.set_style('height','25%');
this.localVodeo.set_style('zIndex', 2);
}
}
init_websocket(){
this.socket = new WebSocket(this.signaling_url);
this.socket.onmessage = this.signaling_message_handle.bind(this);
@ -336,6 +357,15 @@ bricks.RTCClient = class extends bricks.VBox {
}
async connection_statechange(event){
console.log(`onconnectionstatechange, pc.connectionState is ${this.pc.connectionState}.`);
if (ths.pc.connectionState == 'disconnected'){
var w = new bricks.Error({
title:'Error',
message:'lose connection',
timeout:4
});
w.open();
this.call_close();
}
}
ice_g_statechange(event){
console.log(`onicegatheringstatechange, pc.iceGatheringState is ${this.pc.iceGatheringState}.`);