-
Notifications
You must be signed in to change notification settings - Fork 39
/
index.htm
213 lines (167 loc) · 6.83 KB
/
index.htm
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<html>
<head>
<!-- JQuery. Skype for Web requires JQuery to work. -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Bootstrap layouts and themes. Totally optional, but it makes the examples look much nicer :) -->
<link rel="stylesheet" type="text/css" href="../../assets/metro/css/metro-bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<!-- This is the Skype Web SDK -->
<script type="text/javascript" src="//swx.cdn.skype.com/shared/v/1.1.23.0/SkypeBootstrap.js"></script>
</head>
<body>
<div id="header"></div>
<!-- Skype Web SDK Code by Tom Morgan | thoughtstuff.co.uk -->
<!-- This is one of a number of examples showing how to use the Skype Web SDK. The full list is at skypewebsdk.com -->
<!-- Disclaimer: use at your own risk. -->
<div class="form-horizontal">
<div class="form-group">
<label for="username" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="username" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="password" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button class="btn btn-default" id="btnLogIn">Log in</button>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button class="btn btn-default" id="btnLogOut">Log out</button>
</div>
</div>
</div>
<div>
<span id="loginStatus"></span>
</div>
<hr/>
<div class="form-horizontal">
<div class="form-group">
<label for="contact" class="col-sm-2 control-label">Start Audio Call with:</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="contact" placeholder="Contact SIP Address">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button class="btn btn-default" id="btnStartConversation" disabled="disabled">Start</button>
<button class="btn btn-default" id="btnStopConversation" disabled="disabled">Stop</button>
<button class="btn btn-default" id="btnMute" disabled="disabled">Mute / Unmute</button>
<button class="btn btn-default" id="btnHold" disabled="disabled">Hold / Resume</button>
<button class="btn btn-default" id="btnSendDTMF" disabled="disabled">SendDTMF</button>
</div>
</div>
</div>
<div>
<span id="audioStatus"></span>
</div>
<div id="footer"></div>
<!-- This is not needed for the samples to run, but adds standard headers and footers to the samples, to display title, instructions, about etc.
If you're taking this code and using it yourself, you can remove this.-->
<script type="text/javascript" src="../../assets/layoutcodesample-min.js"></script>
<script type="text/javascript">
<!-- These variables are only needed for laying out the code sample, they are not part of the sample code. -->
var pageTitle = 'Mute, Hold & DTMF Tones';
var blogPostLocation = "http://blog.thoughtstuff.co.uk/2015/06/learn-skype-web-sdk-day-23-mute-hold-and-dtmf-tones/";
var githubLocation = "https://github.com/tomorgan/SkypeWebSDKSamples/blob/gh-pages/AV/4-MuteHoldAndDTMF/index.htm";
var client;
$(function () {
'use strict';
Skype.initialize({
apiKey: 'SWX-BUILD-SDK',
}, function (api) {
client = new api.application();
// whenever client.state changes, display its value
client.signInManager.state.changed(function (state) {
$('#loginStatus').text("Login State: " + state);
});
}, function (err) {
alert('Error loading Skype Web SDK: ' + err);
});
$('#btnLogIn').click(function () {
// start signing in
client.signInManager.signIn({
username: $('#username').val(),
password: $('#password').val()
}).then(function () {
//log in worked!
alert('Logged in!');
$('#btnStartConversation').prop('disabled', false);
$('#btnStopConversation').prop('disabled', false);
$('#btnMute').prop('disabled', false);
$('#btnHold').prop('disabled', false);
$('#btnSendDTMF').prop('disabled', false);
}, function (error) {
//Something went wrong.
alert(error);
});
});
$('#btnLogOut').click(function () {
// start signing out
client.signInManager.signOut()
.then(function () {
//log out worked!
alert('Logged out!');
$('#btnStartConversation').prop('disabled', true);
$('#btnStopConversation').prop('disabled', true);
$('#btnMute').prop('disabled', true);
$('#btnHold').prop('disabled', true);
$('#btnSendDTMF').prop('disabled', true);
}, function (error) {
//Something went wrong.
alert(error);
});
});
$('#btnStartConversation').click(function () {
StartConversation($('#contact').val());
});
$('#btnStopConversation').click(function() {
conversation.leave();
});
$('#btnMute').click(function() {
conversation.selfParticipant.audio.isMuted.set(!conversation.selfParticipant.audio.isMuted());
});
$('#btnHold').click(function() {
conversation.selfParticipant.audio.isOnHold.set(!conversation.selfParticipant.audio.isOnHold());
});
$('#btnSendDTMF').click(function() {
conversation.audioService.sendDtmf("1");
});
function StartConversation (contactSIP) {
//first, get the person to start a conversation with. Assume one person.
var person;
GetContactFromName(contactSIP).then(function (results) {
results.forEach(function (result) {
person = result.result;
});
//create the conversation object
conversation = client.conversationsManager.createConversation();
//add the person to the conversation by creating a conversation participant object
var convParticipant = conversation.createParticipant(person);
conversation.participants.add(convParticipant);
//add the newly created conversation to the ConversationManager list
client.conversationsManager.conversations.add(conversation);
conversation.audioService.start();
//watch the audio state of the self-participant to see what's happening
conversation.selfParticipant.audio.state.changed(function(newState) {
$('#audioStatus').text("Audio State: " + newState);
});
});
}
function GetContactFromName(contactSIP)
{
var query = client.personsAndGroupsManager.createPersonSearchQuery();
query.text(contactSIP);
query.limit(1);
return query.getMore();
}
});
</script>
</body>
</html>