forked from murugancmi/nari
-
Notifications
You must be signed in to change notification settings - Fork 0
/
murugan.html
101 lines (83 loc) · 2.82 KB
/
murugan.html
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<html>
<head>
<title>
Murugan
</title>
<!--
<script src="socket.io.js"></script>
<script src="cmiRTC.js"></script>
<script src="cmiChannel.js"></script>
-->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<script src="http://liksu.github.io/ng-chatbox/chatbox.min.js"></script>
<!-- <script src="socket.io.js"></script>
<script src="cmiRTC.js"></script>
<script src="cmiChannel.js"></script> -->
<script src="nari.min.js"></script>
<script>
angular.module('telecmi', ['ngChatbox']).controller('homeController', function($scope) {
$scope.messages = [];
$scope.sendmsg = function() {
telecmi.sendMSG({
msg: $scope.msg
})
$scope.msg=null;
};
var telecmi = new nari();
telecmi.onFire = function(event) {
}
telecmi.onRTC = function(event) {
if (event.event == 'invite') {
telecmi.accept();
}
}
telecmi.onMSG = function(data) {
$scope.$apply(function() {
$scope.messages.push({
time: new Date().toISOString().replace(/T/, ' ').substr(0, 19),
text: data.msg,
own: Math.random() > 0.5 ? 'their' : 'mine'
});
});
}
telecmi.onChannel = function(event) {
console.log(event)
}
telecmi.onlocalstream = function(stream) {
console.log('local stream')
console.error(stream)
}
telecmi.onremotestream = function(stream) {
console.log('remote stream')
console.error(stream)
var remote = document.getElementById('remote')
var src = URL.createObjectURL(stream.stream);
remote.src = src;
}
function send() {
telecmi.sendMSG({
name: 'Murugan',
year: '2016'
})
}
/*
setTimeout(function(){
telecmi.audioCall(9);
},2000)*/
telecmi.register('murugan');
$scope.bye = function() {
telecmi.bye();
}
});
</script>
</head>
<body ng-app="telecmi" ng-controller="homeController">
<video id="local" muted="true" autoplay="true"></video>
<button ng-click="bye()">Hangup</button>
<video id="remote" autoplay="true"></video>
<ng-chatbox ng-model="messages"></ng-chatbox>
<br>
<textarea ng-model="msg"></textarea>
<button ng-click="sendmsg()">Send</button>
</body>
</html>