util.js
1.67 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
var server = null;
if(window.location.protocol === 'http:')
server = "https://janusctest.uccc.cc:24000/janus";
else
server = "https://janusctest.uccc.cc:24000/janus";
var janus = null;
var roomhandler = null;
var feeds = [];
//初始化
function init() {
Janus.init({debug: "all", callback: function() {
if(!Janus.isWebrtcSupported()) {
bootbox.alert("No WebRTC support... ");
return;
}
janus = new Janus({
server: server,
success: function() {
videoroom(i, body)
},
error: function(error) {
Janus.error(error);
bootbox.alert(error, function() {
window.location.reload();
});
},
destroyed: function() {
window.location.reload();
}
})
}
})
}
function videoroom(i, body) {
janus.attach({
plugin: "janus.plugin.videoroom",
opaqueId: "videoroom-"+Janus.randomString(12),
success: function(pluginHandle) {
roomhandler = pluginHandle;
if (i == 1) {
creatRoom(body);
}
},
error: function(error) {
},
consentDialog: function(on) {
},
mediaState: function(medium, on) {
},
webrtcState: function(on) {
},
onmessage: function(msg, jsep) {
},
onlocalstream: function(stream) {
},
onremotestream: function(stream) {
},
oncleanup: function() {
}
});
}
function creatRoom(create) {
Janus.log("插件 (" + roomhandler.getPlugin() + ", id=" + roomhandler.getId() + ")");
roomhandler.send({"message": create, success: function(result) {
var event = result["videoroom"];
if (event === "created") {
// url = "./home.html?name="+111+"&age="+12;
// window.location = url;
} else {
Janus.debug("创建会议失败: " + result["error"]);
janus.destroy();
}
}
});
}