Add semicolons to unify JS format

This commit is contained in:
Deepslient 2023-09-02 11:24:01 +08:00 committed by 夏楚
parent c83a3c5639
commit 6fa4d1b92f

View File

@ -89,12 +89,12 @@
</div>
<script>
var player = null
var recvOnly = true
var resArr = []
var player = null;
var recvOnly = true;
var resArr = [];
var ishttps = 'https:' == document.location.protocol ? true : false
var isLocal = "file:" == document.location.protocol ? true : false
var ishttps = 'https:' == document.location.protocol ? true : false;
var isLocal = "file:" == document.location.protocol ? true : false;
const searchParams = new URL(document.location.href).searchParams;
let type = searchParams.get('type');
@ -105,19 +105,19 @@
const apiPath = `/index/api/webrtc?app=${searchParams.get('app') ?? 'live'}&stream=${searchParams.get('stream') ?? 'test'}&type=${type}`;
if(!ishttps && !isLocal){
alert('本demo需要在https的网站访问 ,如果你要推流的话(this demo must access in site of https if you want push stream)')
alert('本demo需要在https的网站访问 ,如果你要推流的话(this demo must access in site of https if you want push stream)');
}
const apiHost = isLocal ? "http://127.0.0.1" : `${document.location.protocol}//${window.location.host}`;
var url = apiHost + apiPath;
document.getElementById('streamUrl').value = url
document.getElementById('streamUrl').value = url;
document.getElementsByName("method").forEach((el,idx) => {
el.checked = el.value === type;
el.onclick = function(e) {
let url = new URL(document.getElementById('streamUrl').value);
url.searchParams.set("type",el.value);
document.getElementById('streamUrl').value = url.toString()
document.getElementById('streamUrl').value = url.toString();
if(el.value == "play"){
recvOnly = true;
@ -136,7 +136,7 @@
if (1080*720 <= r.width * r.height && r.width * r.height <= 1280*720) {
opt.selected = true;
}
document.getElementById("resolution").add(opt,null)
document.getElementById("resolution").add(opt,null);
});
function start_play(){
@ -162,17 +162,17 @@
player.on(ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR,function(e)
{// ICE 协商出错
console.log('ICE 协商出错')
console.log('ICE 协商出错');
});
player.on(ZLMRTCClient.Events.WEBRTC_ON_REMOTE_STREAMS,function(e)
{//获取到了远端流,可以播放
console.log('播放成功',e.streams)
console.log('播放成功',e.streams);
});
player.on(ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED,function(e)
{// offer anwser 交换失败
console.log('offer anwser 交换失败',e)
console.log('offer anwser 交换失败',e);
stop();
});
@ -188,31 +188,31 @@
player.on(ZLMRTCClient.Events.CAPTURE_STREAM_FAILED,function(s)
{// 获取本地流失败
console.log('获取本地流失败')
console.log('获取本地流失败');
});
player.on(ZLMRTCClient.Events.WEBRTC_ON_CONNECTION_STATE_CHANGE,function(state)
{// RTC 状态变化 ,详情参考 https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/connectionState
console.log('当前状态==>',state)
console.log('当前状态==>',state);
});
player.on(ZLMRTCClient.Events.WEBRTC_ON_DATA_CHANNEL_OPEN,function(event)
{
console.log('rtc datachannel 打开 :',event)
console.log('rtc datachannel 打开 :',event);
});
player.on(ZLMRTCClient.Events.WEBRTC_ON_DATA_CHANNEL_MSG,function(event)
{
console.log('rtc datachannel 消息 :',event.data)
document.getElementById('msgrecv').value = event.data
console.log('rtc datachannel 消息 :',event.data);
document.getElementById('msgrecv').value = event.data;
});
player.on(ZLMRTCClient.Events.WEBRTC_ON_DATA_CHANNEL_ERR,function(event)
{
console.log('rtc datachannel 错误 :',event)
console.log('rtc datachannel 错误 :',event);
});
player.on(ZLMRTCClient.Events.WEBRTC_ON_DATA_CHANNEL_CLOSE,function(event)
{
console.log('rtc datachannel 关闭 :',event)
console.log('rtc datachannel 关闭 :',event);
});
}
@ -227,12 +227,12 @@
if(document.getElementById('useCamera').checked && !recvOnly)
{
ZLMRTCClient.isSupportResolution(w,h).then(e=>{
start_play()
start_play();
}).catch(e=>{
alert("not support resolution")
alert("not support resolution");
});
}else{
start_play()
start_play();
}
}
@ -257,13 +257,13 @@
function send(){
if(player){
//send msg refernece https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/send
player.sendMsg(document.getElementById('msgsend').value)
player.sendMsg(document.getElementById('msgsend').value);
}
}
function close(){
if(player){
player.closeDataChannel()
player.closeDataChannel();
}
}