mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
Add semicolons to unify JS format
This commit is contained in:
parent
c83a3c5639
commit
6fa4d1b92f
@ -89,12 +89,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var player = null
|
var player = null;
|
||||||
var recvOnly = true
|
var recvOnly = true;
|
||||||
var resArr = []
|
var resArr = [];
|
||||||
|
|
||||||
var ishttps = 'https:' == document.location.protocol ? true : false
|
var ishttps = 'https:' == document.location.protocol ? true : false;
|
||||||
var isLocal = "file:" == document.location.protocol ? true : false
|
var isLocal = "file:" == document.location.protocol ? true : false;
|
||||||
|
|
||||||
const searchParams = new URL(document.location.href).searchParams;
|
const searchParams = new URL(document.location.href).searchParams;
|
||||||
let type = searchParams.get('type');
|
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}`;
|
const apiPath = `/index/api/webrtc?app=${searchParams.get('app') ?? 'live'}&stream=${searchParams.get('stream') ?? 'test'}&type=${type}`;
|
||||||
|
|
||||||
if(!ishttps && !isLocal){
|
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}`;
|
const apiHost = isLocal ? "http://127.0.0.1" : `${document.location.protocol}//${window.location.host}`;
|
||||||
var url = apiHost + apiPath;
|
var url = apiHost + apiPath;
|
||||||
|
|
||||||
document.getElementById('streamUrl').value = url
|
document.getElementById('streamUrl').value = url;
|
||||||
document.getElementsByName("method").forEach((el,idx) => {
|
document.getElementsByName("method").forEach((el,idx) => {
|
||||||
el.checked = el.value === type;
|
el.checked = el.value === type;
|
||||||
el.onclick = function(e) {
|
el.onclick = function(e) {
|
||||||
let url = new URL(document.getElementById('streamUrl').value);
|
let url = new URL(document.getElementById('streamUrl').value);
|
||||||
url.searchParams.set("type",el.value);
|
url.searchParams.set("type",el.value);
|
||||||
document.getElementById('streamUrl').value = url.toString()
|
document.getElementById('streamUrl').value = url.toString();
|
||||||
|
|
||||||
if(el.value == "play"){
|
if(el.value == "play"){
|
||||||
recvOnly = true;
|
recvOnly = true;
|
||||||
@ -136,7 +136,7 @@
|
|||||||
if (1080*720 <= r.width * r.height && r.width * r.height <= 1280*720) {
|
if (1080*720 <= r.width * r.height && r.width * r.height <= 1280*720) {
|
||||||
opt.selected = true;
|
opt.selected = true;
|
||||||
}
|
}
|
||||||
document.getElementById("resolution").add(opt,null)
|
document.getElementById("resolution").add(opt,null);
|
||||||
});
|
});
|
||||||
|
|
||||||
function start_play(){
|
function start_play(){
|
||||||
@ -162,17 +162,17 @@
|
|||||||
|
|
||||||
player.on(ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR,function(e)
|
player.on(ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR,function(e)
|
||||||
{// ICE 协商出错
|
{// ICE 协商出错
|
||||||
console.log('ICE 协商出错')
|
console.log('ICE 协商出错');
|
||||||
});
|
});
|
||||||
|
|
||||||
player.on(ZLMRTCClient.Events.WEBRTC_ON_REMOTE_STREAMS,function(e)
|
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)
|
player.on(ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED,function(e)
|
||||||
{// offer anwser 交换失败
|
{// offer anwser 交换失败
|
||||||
console.log('offer anwser 交换失败',e)
|
console.log('offer anwser 交换失败',e);
|
||||||
stop();
|
stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -188,31 +188,31 @@
|
|||||||
player.on(ZLMRTCClient.Events.CAPTURE_STREAM_FAILED,function(s)
|
player.on(ZLMRTCClient.Events.CAPTURE_STREAM_FAILED,function(s)
|
||||||
{// 获取本地流失败
|
{// 获取本地流失败
|
||||||
|
|
||||||
console.log('获取本地流失败')
|
console.log('获取本地流失败');
|
||||||
});
|
});
|
||||||
|
|
||||||
player.on(ZLMRTCClient.Events.WEBRTC_ON_CONNECTION_STATE_CHANGE,function(state)
|
player.on(ZLMRTCClient.Events.WEBRTC_ON_CONNECTION_STATE_CHANGE,function(state)
|
||||||
{// RTC 状态变化 ,详情参考 https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/connectionState
|
{// 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)
|
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)
|
player.on(ZLMRTCClient.Events.WEBRTC_ON_DATA_CHANNEL_MSG,function(event)
|
||||||
{
|
{
|
||||||
console.log('rtc datachannel 消息 :',event.data)
|
console.log('rtc datachannel 消息 :',event.data);
|
||||||
document.getElementById('msgrecv').value = event.data
|
document.getElementById('msgrecv').value = event.data;
|
||||||
});
|
});
|
||||||
player.on(ZLMRTCClient.Events.WEBRTC_ON_DATA_CHANNEL_ERR,function(event)
|
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)
|
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)
|
if(document.getElementById('useCamera').checked && !recvOnly)
|
||||||
{
|
{
|
||||||
ZLMRTCClient.isSupportResolution(w,h).then(e=>{
|
ZLMRTCClient.isSupportResolution(w,h).then(e=>{
|
||||||
start_play()
|
start_play();
|
||||||
}).catch(e=>{
|
}).catch(e=>{
|
||||||
alert("not support resolution")
|
alert("not support resolution");
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
start_play()
|
start_play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,13 +257,13 @@
|
|||||||
function send(){
|
function send(){
|
||||||
if(player){
|
if(player){
|
||||||
//send msg refernece https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/send
|
//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(){
|
function close(){
|
||||||
if(player){
|
if(player){
|
||||||
player.closeDataChannel()
|
player.closeDataChannel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user