feat: 优化代码,增加server配置

This commit is contained in:
wangyu 2023-12-18 09:43:58 +08:00
parent 879eb2c012
commit 130a2b04f1
3 changed files with 10 additions and 10 deletions

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
<title>Janus WebRTC 视频播放</title>
</head>
<body>
<div id="app"></div>

View File

@ -6,7 +6,7 @@ const { play, stop, streams, stream, status, error } = useJanus({ autoplay: true
const selected = ref(null)
const watch = () => play(selected.value);
const watch = () => play(selected.value)
</script>
@ -32,22 +32,26 @@ const watch = () => play(selected.value);
.video-wrapper {
padding: 20px;
text-align: center;
select {
width: 100%;
height: 40px;
margin-bottom: 20px;
}
.control {
display: flex;
justify-content: center;
align-items: center;
}
button {
width: 100px;
height: 30px;
margin-right: 20px;
margin-bottom: 20px;
}
video {
max-width: 1000px;
min-width: 800px;

View File

@ -6,13 +6,7 @@ export {
Janus
}
const log = {
info(...msg) {
Janus.log(...msg)
}
}
const config = {
const defaultConfig = {
server: 'http://10.211.55.6:8088/janus'
}
@ -207,7 +201,9 @@ export function useJanus(options) {
const start = async () => {
try {
janus = await connect(config)
janus = await connect({
server: options.server || defaultConfig.server
})
streaming = await plugin(janus, StreamPlugin())
if (options.autoplay) {
await fetchStreams()