‘liusuyi’
2023-07-27 e279e456850734349842edd8ce52dc16fc5cdea7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
<script src="libs/adapter.min.js" ></script>
<script src="webrtcstreamer.js" ></script>
<script src="webrtcconfig.js" ></script>
<script>        
    let video = "";  
    let options = webrtcConfig.options;
    if (location.search.slice(1)) {
        if (typeof URLSearchParams != 'undefined') {
            var params = new URLSearchParams(location.search);
            if (params.has("video")) {
                video = params.get("video");
            }
            if (params.has("options")) {
                options = params.get("options");
            }
        }         
   }
 
   window.onload         = function() { 
        this.webRtcServer      = new WebRtcStreamer("remotevideo", webrtcConfig.url);
        navigator.mediaDevices.getUserMedia({video: true, audio: true}).then(stream => {
        
            var videoElement = document.getElementById("localvideo");
            videoElement.srcObject = stream;
            videoElement.play(); 
    
            this.webRtcServer.connect(video, "", options, stream) 
        })
    }
    window.onbeforeunload = function() { this.webRtcServer.disconnect() }
 
</script>
</head>
<body> 
    <div>
        <video id="localvideo" ></video>
    </div>
    <div>    
        <video id="remotevideo" muted playsinline></video>    
    </div>
</body>
</html>