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"> <meta charset="UTF-8">
<link rel="icon" href="/favicon.ico"> <link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title> <title>Janus WebRTC 视频播放</title>
</head> </head>
<body> <body>
<div id="app"></div> <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 selected = ref(null)
const watch = () => play(selected.value); const watch = () => play(selected.value)
</script> </script>
@ -32,22 +32,26 @@ const watch = () => play(selected.value);
.video-wrapper { .video-wrapper {
padding: 20px; padding: 20px;
text-align: center; text-align: center;
select { select {
width: 100%; width: 100%;
height: 40px; height: 40px;
margin-bottom: 20px; margin-bottom: 20px;
} }
.control { .control {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
button { button {
width: 100px; width: 100px;
height: 30px; height: 30px;
margin-right: 20px; margin-right: 20px;
margin-bottom: 20px; margin-bottom: 20px;
} }
video { video {
max-width: 1000px; max-width: 1000px;
min-width: 800px; min-width: 800px;

View File

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