@flashphoner/websdk 2.0.210 → 2.0.211

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- Web SDK - 2.0.210
1
+ Web SDK - 2.0.211
2
2
 
3
3
  [Download builds](https://docs.flashphoner.com/display/WEBSDK2EN/Web+SDK+release+notes)
4
4
 
@@ -66,6 +66,9 @@
66
66
  <div class="text-center" style="margin-top: 20px">
67
67
  <div id="participant1Status"></div>
68
68
  </div>
69
+ <div class="input-group text-center" style="margin: 5px auto 0 auto;">
70
+ <button id="participant1Btn" type="button" class="btn btn-default">Play</button>
71
+ </div>
69
72
  </div>
70
73
 
71
74
  <div class="col-sm-6">
@@ -76,6 +79,9 @@
76
79
  <div class="text-center" style="margin-top: 20px">
77
80
  <div id="participant2Status"></div>
78
81
  </div>
82
+ <div class="input-group text-center" style="margin: 5px auto 0 auto;">
83
+ <button id="participant2Btn" type="button" class="btn btn-default">Play</button>
84
+ </div>
79
85
  </div>
80
86
 
81
87
  </div>
@@ -47,6 +47,9 @@ function onLeft() {
47
47
  $("[id$=Name]").not(":contains('NONE')").each(function(index,value) {
48
48
  $(value).text('NONE');
49
49
  });
50
+ for (var i = 0; i < _participants; i++) {
51
+ $("#participant" + i + "Btn").text("Play").off('click').prop('disabled', true);
52
+ };
50
53
  $("#joinBtn").text("Join").off('click').click(function(){
51
54
  if (validateForm()) {
52
55
  $(this).prop('disabled', true);
@@ -75,14 +78,6 @@ function start() {
75
78
  return;
76
79
  }
77
80
  }
78
- if (Browser.isSafariWebRTC()) {
79
- for (var i = 1; i < _participants; i++){
80
- Flashphoner.playFirstVideo(document.getElementById("participant" + i + "Display"), false, PRELOADER_URL).then(function() {
81
- createConnection(url, username);
82
- });
83
- return;
84
- }
85
- }
86
81
  createConnection(url, username);
87
82
  }
88
83
 
@@ -123,14 +118,7 @@ function joinRoom() {
123
118
  } else {
124
119
  addMessage("chat", " room is empty");
125
120
  }
126
- if (Browser.isSafariWebRTC()) {
127
- Flashphoner.playFirstVideo(document.getElementById("localDisplay"), true, PRELOADER_URL).then(function() {
128
- publishLocalMedia(room);
129
- onJoined(room);
130
- });
131
- return;
132
- }
133
- publishLocalMedia(room);
121
+ publishLocalStream(room);
134
122
  onJoined(room);
135
123
  }).on(ROOM_EVENT.JOINED, function(participant){
136
124
  installParticipant(participant);
@@ -164,7 +152,6 @@ function installParticipant(participant) {
164
152
  } else {
165
153
  var p = $("[id$=Name]:contains('NONE')")[0].id.replace('Name','');
166
154
  var pName = '#' + p + 'Name';
167
- var pDisplay = p + 'Display';
168
155
  $(pName).text(participant.name());
169
156
  playParticipantsStream(participant);
170
157
  }
@@ -174,6 +161,8 @@ function removeParticipant(participant) {
174
161
  $("[id$=Name]").each(function(index,value) {
175
162
  if ($(value).text() == participant.name()) {
176
163
  $(value).text('NONE');
164
+ var pButtonId = value.id.replace('Name', '') + 'Btn';
165
+ $("#" + pButtonId).text("Play").off('click').prop('disabled', true);
177
166
  }
178
167
  });
179
168
  }
@@ -183,17 +172,68 @@ function playParticipantsStream(participant) {
183
172
  $("[id$=Name]").each(function (index, value) {
184
173
  if ($(value).text() == participant.name()) {
185
174
  var p = value.id.replace('Name', '');
186
- var pDisplay = p + 'Display';
187
- participant.getStreams()[0].play(document.getElementById(pDisplay)).on(STREAM_STATUS.PLAYING, function (playingStream) {
188
- document.getElementById(playingStream.id()).addEventListener('resize', function (event) {
189
- resizeVideo(event.target);
175
+ var pDisplay = document.getElementById(p + 'Display');
176
+ if (Browser.isSafariWebRTC()) {
177
+ Flashphoner.playFirstVideo(pDisplay, false, PRELOADER_URL).then(function() {
178
+ playStream(participant, pDisplay);
179
+ }).catch(function (error) {
180
+ // Low Power Mode detected, user action is needed to start playback in this mode #WCS-2639
181
+ console.log("Can't atomatically play participant" + participant.name() + " stream, use Play button");
182
+ for (var i = 0; i < pDisplay.children.length; i++) {
183
+ if (pDisplay.children[i]) {
184
+ console.log("remove cached instance id " + pDisplay.children[i].id);
185
+ pDisplay.removeChild(pDisplay.children[i]);
186
+ }
187
+ }
188
+ onParticipantStopped(participant);
190
189
  });
191
- });
190
+ } else {
191
+ playStream(participant, pDisplay);
192
+ }
192
193
  }
193
194
  });
194
195
  }
195
196
  }
196
197
 
198
+ function playStream(participant, display) {
199
+ var button = getParticipantButton(participant);
200
+ participant.getStreams()[0].play(display).on(STREAM_STATUS.PLAYING, function (playingStream) {
201
+ document.getElementById(playingStream.id()).addEventListener('resize', function (event) {
202
+ resizeVideo(event.target);
203
+ });
204
+ if (button) {
205
+ $(button).text("Stop").off('click').click(function(){
206
+ $(this).prop('disabled', true);
207
+ playingStream.stop();
208
+ }).prop('disabled', false);
209
+ }
210
+ }).on(STREAM_STATUS.STOPPED, function () {
211
+ onParticipantStopped(participant);
212
+ }).on(STREAM_STATUS.FAILED, function () {
213
+ onParticipantStopped(participant);
214
+ });
215
+ }
216
+
217
+ function onParticipantStopped(participant) {
218
+ var button = getParticipantButton(participant);
219
+ if (button) {
220
+ $(button).text("Play").off('click').click(function() {
221
+ playParticipantsStream(participant);
222
+ }).prop('disabled', false);
223
+ }
224
+ }
225
+
226
+ function getParticipantButton(participant) {
227
+ var button = null;
228
+ $("[id$=Name]").each(function (index, value) {
229
+ if ($(value).text() == participant.name()) {
230
+ button = document.getElementById(value.id.replace('Name', '') + 'Btn');
231
+ return(button);
232
+ }
233
+ });
234
+ return(button);
235
+ }
236
+
197
237
  function getRoomName() {
198
238
  var name = getUrlParam("roomName");
199
239
  if (name && name !== '') {
@@ -239,7 +279,7 @@ function onMediaPublished(stream) {
239
279
  function onMediaStopped(room) {
240
280
  $("#localStopBtn").text("Publish").off('click').click(function(){
241
281
  $(this).prop('disabled', true);
242
- publishLocalMedia(room);
282
+ publishLocalStream(room);
243
283
  }).prop('disabled', (connection.getRooms().length == 0));
244
284
  $("#localAudioToggle").prop("disabled", true);
245
285
  $("#localVideoToggle").prop("disabled", true);
@@ -274,6 +314,26 @@ function publishLocalMedia(room) {
274
314
  });
275
315
  }
276
316
 
317
+ function publishLocalStream(room) {
318
+ if (Browser.isSafariWebRTC()) {
319
+ var display = document.getElementById("localDisplay");
320
+ Flashphoner.playFirstVideo(display, true, PRELOADER_URL).then(function() {
321
+ publishLocalMedia(room);
322
+ }).catch(function (error) {
323
+ console.log("Can't atomatically publish local stream, use Publish button");
324
+ for (var i = 0; i < display.children.length; i++) {
325
+ if (display.children[i]) {
326
+ console.log("remove cached instance id " + display.children[i].id);
327
+ display.removeChild(display.children[i]);
328
+ }
329
+ }
330
+ onMediaStopped(room);
331
+ });
332
+ return;
333
+ }
334
+ publishLocalMedia(room);
335
+ }
336
+
277
337
  function muteConnectInputs() {
278
338
  $(':text').each(function(){
279
339
  $(this).prop('disabled', true);
@@ -10149,7 +10149,7 @@ var createSession = function createSession(options) {
10149
10149
  mediaProviders: Object.keys(MediaProvider),
10150
10150
  keepAlive: keepAlive,
10151
10151
  authToken: authToken,
10152
- clientVersion: "2.0.210",
10152
+ clientVersion: "2.0.211",
10153
10153
  clientOSVersion: window.navigator.appVersion,
10154
10154
  clientBrowserVersion: window.navigator.userAgent,
10155
10155
  msePacketizationVersion: 2,