Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
bb37bce3
Commit
bb37bce3
authored
Jun 07, 2021
by
xgj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update zlmrtcclient.js
parent
0f3a8f4a
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
392 行增加
和
213 行删除
+392
-213
www/webrtc/ZLMRTCClient.js
+200
-19
www/webrtc/ZLMRTCClient.js.map
+0
-0
www/webrtc/index.html
+192
-96
www/webrtc/index_push.html
+0
-98
没有找到文件。
www/webrtc/ZLMRTCClient.js
查看文件 @
bb37bce3
差异被折叠。
点击展开。
www/webrtc/ZLMRTCClient.js.map
查看文件 @
bb37bce3
This source diff could not be displayed because it is too large. You can
view the blob
instead.
www/webrtc/index
_play
.html
→
www/webrtc/index.html
查看文件 @
bb37bce3
<html>
<html>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<head>
<head>
<title>
ZLM RTC demo
</title>
<title>
ZLM RTC demo
</title>
<script
src=
"./ZLMRTCClient.js"
></script>
<script
src=
"./ZLMRTCClient.js"
></script>
</head>
</head>
<body>
<body>
<div
style=
"text-align: center;"
>
<div
style=
"text-align: center;"
>
<div>
<div>
<video
id=
'video'
controls
autoplay
style=
"text-align:left;"
>
<video
id=
'video'
controls
autoplay
style=
"text-align:left;"
>
Your browser is too old which doesn't support HTML5 video.
Your browser is too old which doesn't support HTML5 video.
</video>
</video>
<video
id=
'selfVideo'
controls
autoplay
style=
"text-align:right;"
>
<video
id=
'selfVideo'
controls
autoplay
style=
"text-align:right;"
>
Your browser is too old which doesn't support HTML5 video.
Your browser is too old which doesn't support HTML5 video.
</video>
</video>
</div>
</div>
<div>
<div>
<p>
<p>
<label
for=
"streamUrl"
>
url:
</label>
<label
for=
"streamUrl"
>
url:
</label>
<input
type=
"text"
id=
'streamUrl'
value=
"http://127.0.0.1/index/api/webrtc?app=live&stream=test&type=play"
>
<input
type=
"text"
style=
"co"
id=
'streamUrl'
value=
"http://127.0.0.1/index/api/webrtc?app=live&stream=test&type=play"
>
</p>
</p>
<p>
<p>
<label
for=
"simulecast"
>
simulecast:
</label>
<label
for=
"simulecast"
>
simulecast:
</label>
<input
type=
"checkbox"
id=
'simulecast'
>
<input
type=
"checkbox"
id=
'simulecast'
checked=
"checked"
>
</p>
</p>
<button
onclick=
"start()"
>
开始
</button>
<p>
<button
onclick=
"stop()"
>
停止
</button>
<label
for=
"useCamera"
>
useCamera:
</label>
<input
type=
"checkbox"
id=
'useCamera'
checked=
"checked"
>
</div>
</p>
</div>
<script>
<p>
var
player
=
null
<label
for=
"audioEnable"
>
audioEnable:
</label>
function
start
()
<input
type=
"checkbox"
id=
'audioEnable'
checked=
"checked"
>
{
</p>
stop
();
player
=
new
ZLMRTCClient
.
Endpoint
(
<p>
{
<label
for=
"videoEnable"
>
videoEnable:
</label>
element
:
document
.
getElementById
(
'video'
),
// video 标签
<input
type=
"checkbox"
id=
'videoEnable'
checked=
"checked"
>
debug
:
true
,
// 是否打印日志
</p>
zlmsdpUrl
:
document
.
getElementById
(
'streamUrl'
).
value
,
//流地址
simulecast
:
document
.
getElementById
(
'simulecast'
).
checked
<p>
}
<label
for=
"methond"
>
methond(play or push):
</label>
);
<input
type=
"radio"
name=
"methond"
value=
"push"
>
push
<input
type=
"radio"
name=
"methond"
value=
"play"
checked =
true
>
play
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_ICE_CANDIDATE_ERROR
,
function
(
e
)
</p>
{
// ICE 协商出错
console
.
log
(
'ICE 协商出错'
)
<p>
});
<label
for=
"resilution"
>
resolution:
</label>
<select
id=
"resilution"
>
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_ON_REMOTE_STREAMS
,
function
(
e
)
{
//获取到了远端流,可以播放
</select>
console
.
log
(
'播放成功'
,
e
.
streams
)
</p>
});
<button
onclick=
"start()"
>
开始
</button>
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED
,
function
(
e
)
<button
onclick=
"stop()"
>
停止
</button>
{
// offer anwser 交换失败
console
.
log
(
'offer anwser 交换失败'
,
e
)
</div>
});
</div>
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_ON_LOCAL_STREAM
,
function
(
s
)
<script>
{
// 获取到了本地流
var
player
=
null
var
recvOnly
=
true
document
.
getElementById
(
'selfVideo'
).
srcObject
=
s
;
var
resArr
=
[]
//console.log('offer anwser 交换失败',e)
document
.
getElementsByName
(
"methond"
).
forEach
((
el
,
idx
)
=>
{
});
el
.
onclick
=
function
(
e
){
if
(
el
.
value
==
"play"
)
}
{
let
url
=
document
.
getElementById
(
'streamUrl'
).
value
;
function
stop
()
{
document
.
getElementById
(
'streamUrl'
).
value
=
url
.
replace
(
"&type=push"
,
"&type=play"
);
if
(
player
)
recvOnly
=
true
;
{
}
player
.
close
();
else
player
=
null
;
{
var
local
=
document
.
getElementById
(
'selfVideo'
);
let
url
=
document
.
getElementById
(
'streamUrl'
).
value
;
local
.
removeAttribute
(
'srcObject'
);
document
.
getElementById
(
'streamUrl'
).
value
=
url
.
replace
(
"&type=play"
,
"&type=push"
);
local
.
load
();
recvOnly
=
false
;
}
}
}
};
});
</script>
ZLMRTCClient
.
GetAllScanResolution
().
forEach
((
r
,
i
)
=>
{
</body>
opt
=
document
.
createElement
(
'option'
);
opt
.
text
=
r
.
label
+
"("
+
r
.
width
+
"x"
+
r
.
height
+
")"
;
<script>
opt
.
value
=
r
;
document
.
getElementById
(
"resilution"
).
add
(
opt
,
null
)
</script>
//console.log(opt.text.match(/\d+/g))
})
function
start_play
(){
let
elr
=
document
.
getElementById
(
"resilution"
);
let
res
=
elr
.
options
[
elr
.
selectedIndex
].
text
.
match
(
/
\d
+/g
);
let
h
=
parseInt
(
res
.
pop
());
let
w
=
parseInt
(
res
.
pop
());
player
=
new
ZLMRTCClient
.
Endpoint
(
{
element
:
document
.
getElementById
(
'video'
),
// video 标签
debug
:
true
,
// 是否打印日志
zlmsdpUrl
:
document
.
getElementById
(
'streamUrl'
).
value
,
//流地址
simulecast
:
false
,
//document.getElementById('simulecast').checked,
useCamera
:
document
.
getElementById
(
'useCamera'
).
checked
,
audioEnable
:
document
.
getElementById
(
'audioEnable'
).
checked
,
videoEnable
:
document
.
getElementById
(
'videoEnable'
).
checked
,
recvOnly
:
recvOnly
,
resolution
:{
w
:
w
,
h
:
h
}
}
);
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_ICE_CANDIDATE_ERROR
,
function
(
e
)
{
// ICE 协商出错
console
.
log
(
'ICE 协商出错'
)
});
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_ON_REMOTE_STREAMS
,
function
(
e
)
{
//获取到了远端流,可以播放
console
.
log
(
'播放成功'
,
e
.
streams
)
});
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED
,
function
(
e
)
{
// offer anwser 交换失败
console
.
log
(
'offer anwser 交换失败'
,
e
)
stop
();
});
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_ON_LOCAL_STREAM
,
function
(
s
)
{
// 获取到了本地流
document
.
getElementById
(
'selfVideo'
).
srcObject
=
s
;
document
.
getElementById
(
'selfVideo'
).
muted
=
true
;
//console.log('offer anwser 交换失败',e)
});
player
.
on
(
ZLMRTCClient
.
Events
.
CAPTURE_STREAM_FAILED
,
function
(
s
)
{
// 获取本地流失败
console
.
log
(
'获取本地流失败'
)
});
}
function
start
()
{
stop
();
let
elr
=
document
.
getElementById
(
"resilution"
);
let
res
=
elr
.
options
[
elr
.
selectedIndex
].
text
.
match
(
/
\d
+/g
);
let
h
=
parseInt
(
res
.
pop
());
let
w
=
parseInt
(
res
.
pop
());
if
(
document
.
getElementById
(
'useCamera'
).
checked
&&
!
recvOnly
)
{
ZLMRTCClient
.
isSupportResolution
(
w
,
h
).
then
(
e
=>
{
start_play
()
}).
catch
(
e
=>
{
alert
(
"not support resolution"
)
});
}
else
{
start_play
()
}
}
function
stop
()
{
if
(
player
)
{
player
.
close
();
player
=
null
;
var
local
=
document
.
getElementById
(
'selfVideo'
);
local
.
removeAttribute
(
'srcObject'
);
local
.
load
();
}
}
</script>
</body>
<script>
</script>
</html>
</html>
\ No newline at end of file
www/webrtc/index_push.html
deleted
100644 → 0
查看文件 @
0f3a8f4a
<html>
<meta
charset=
"utf-8"
>
<head>
<title>
ZLM RTC demo
</title>
<script
src=
"./ZLMRTCClient.js"
></script>
</head>
<body>
<div
style=
"text-align: center;"
>
<div>
<video
id=
'video'
controls
autoplay
style=
"text-align:left;"
>
Your browser is too old which doesn't support HTML5 video.
</video>
<video
id=
'selfVideo'
controls
autoplay
style=
"text-align:right;"
>
Your browser is too old which doesn't support HTML5 video.
</video>
</div>
<div>
<p>
<label
for=
"streamUrl"
>
url:
</label>
<input
type=
"text"
id=
'streamUrl'
value=
"http://127.0.0.1/index/api/webrtc?app=live&stream=test&type=push"
>
</p>
<p>
<label
for=
"simulecast"
>
simulecast:
</label>
<input
type=
"checkbox"
id=
'simulecast'
>
</p>
<button
onclick=
"start()"
>
开始
</button>
<button
onclick=
"stop()"
>
停止
</button>
</div>
</div>
<script>
var
player
=
null
function
start
()
{
stop
();
player
=
new
ZLMRTCClient
.
Endpoint
(
{
element
:
document
.
getElementById
(
'video'
),
// video 标签
debug
:
true
,
// 是否打印日志
zlmsdpUrl
:
document
.
getElementById
(
'streamUrl'
).
value
,
//流地址
simulecast
:
document
.
getElementById
(
'simulecast'
).
checked
}
);
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_ICE_CANDIDATE_ERROR
,
function
(
e
)
{
// ICE 协商出错
console
.
log
(
'ICE 协商出错'
)
});
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_ON_REMOTE_STREAMS
,
function
(
e
)
{
//获取到了远端流,可以播放
console
.
log
(
'播放成功'
,
e
.
streams
)
});
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED
,
function
(
e
)
{
// offer anwser 交换失败
console
.
log
(
'offer anwser 交换失败'
,
e
)
});
player
.
on
(
ZLMRTCClient
.
Events
.
WEBRTC_ON_LOCAL_STREAM
,
function
(
s
)
{
// 获取到了本地流
document
.
getElementById
(
'selfVideo'
).
srcObject
=
s
;
//console.log('offer anwser 交换失败',e)
});
}
function
stop
()
{
if
(
player
)
{
player
.
close
();
player
=
null
;
var
local
=
document
.
getElementById
(
'selfVideo'
);
local
.
removeAttribute
(
'srcObject'
);
local
.
load
();
}
}
</script>
</body>
<script>
</script>
</html>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论