@flashphoner/websdk 2.0.271 → 2.0.274
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.
- package/docTemplate/README.md +1 -1
- package/examples/demo/streaming/media_devices_manager/manager.js +83 -80
- package/flashphoner-no-flash.js +286 -73
- package/flashphoner-no-flash.min.js +2 -2
- package/flashphoner-no-webrtc.js +85 -33
- package/flashphoner-no-webrtc.min.js +2 -2
- package/flashphoner-no-wsplayer.js +286 -73
- package/flashphoner-no-wsplayer.min.js +2 -2
- package/flashphoner-room-api-webrtc-only.js +286 -73
- package/flashphoner-room-api-webrtc-only.min.js +1 -1
- package/flashphoner-room-api.js +221 -72
- package/flashphoner-room-api.min.js +2 -2
- package/flashphoner-temasys-flash-websocket-without-adapterjs.js +85 -33
- package/flashphoner-temasys-flash-websocket.js +85 -33
- package/flashphoner-temasys-flash-websocket.min.js +1 -1
- package/flashphoner-webrtc-only.js +286 -73
- package/flashphoner-webrtc-only.min.js +1 -1
- package/flashphoner.js +286 -73
- package/flashphoner.min.js +2 -2
- package/package.json +1 -1
- package/src/flashphoner-core.js +67 -27
- package/src/stats-collector.js +12 -1
- package/src/webrtc-media-provider.js +142 -44
package/docTemplate/README.md
CHANGED
|
@@ -34,6 +34,7 @@ var statSpeechDetector = {
|
|
|
34
34
|
threshold: 0.010,
|
|
35
35
|
latency: 750
|
|
36
36
|
};
|
|
37
|
+
var switchCamEnabled = true;
|
|
37
38
|
|
|
38
39
|
try {
|
|
39
40
|
var audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
|
@@ -65,81 +66,43 @@ function init_page() {
|
|
|
65
66
|
|
|
66
67
|
if(Browser.isAndroid() || Browser.isiOS()) {
|
|
67
68
|
$('#screenShareForm').hide();
|
|
69
|
+
if (Browser.isFirefox()) {
|
|
70
|
+
// Use camera selection by name in mobile Firefox browser
|
|
71
|
+
Flashphoner.getMediaDevices(null, true).then(function (list) {
|
|
72
|
+
setSwitchableControls(list.video, "videoInput", "sendVideo");
|
|
73
|
+
setSwitchableControls(list.audio, "audioInput", "sendAudio");
|
|
74
|
+
}).catch(function (error) {
|
|
75
|
+
$("#notifyFlash").text("Failed to get media devices: " + error.message);
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
// Use camera selection by facingMode constraint on mobile devices in Chrome and Safari
|
|
79
|
+
Flashphoner.getMobileDevices(null, MEDIA_DEVICE_KIND.INPUT).then((list) => {
|
|
80
|
+
setSwitchableControls(list.video, "videoInput", "sendVideo");
|
|
81
|
+
setSwitchableControls(list.audio, "audioInput", "sendAudio");
|
|
82
|
+
switchCamEnabled = false;
|
|
83
|
+
}).catch(function (error) {
|
|
84
|
+
$("#notifyFlash").text("Failed to get media devices: " + error.message);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
// List all the connected devices on desktop
|
|
89
|
+
Flashphoner.getMediaDevices(null, true).then(function (list) {
|
|
90
|
+
setSwitchableControls(list.video, "videoInput", "sendVideo");
|
|
91
|
+
setSwitchableControls(list.audio, "audioInput", "sendAudio");
|
|
92
|
+
}).catch(function (error) {
|
|
93
|
+
$("#notifyFlash").text("Failed to get media devices: " + error.message);
|
|
94
|
+
});
|
|
68
95
|
}
|
|
69
96
|
|
|
70
97
|
Flashphoner.getMediaDevices(null, true, MEDIA_DEVICE_KIND.OUTPUT).then(function (list) {
|
|
71
|
-
list.audio
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
for (var i = 0; i < audio.options.length; i++) {
|
|
75
|
-
if (audio.options[i].value === device.id) {
|
|
76
|
-
deviceInList = true;
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (!deviceInList) {
|
|
81
|
-
var option = document.createElement("option");
|
|
82
|
-
option.text = device.label || device.id;
|
|
83
|
-
option.value = device.id;
|
|
84
|
-
audio.appendChild(option);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
98
|
+
if (list.audio) {
|
|
99
|
+
addDeviceToSelect(list.audio, "audioOutput");
|
|
100
|
+
}
|
|
87
101
|
}).catch(function (error) {
|
|
88
102
|
console.error(error);
|
|
89
103
|
$('#audioOutputForm').remove();
|
|
90
104
|
});
|
|
91
105
|
|
|
92
|
-
Flashphoner.getMediaDevices(null, true).then(function (list) {
|
|
93
|
-
list.audio.forEach(function (device) {
|
|
94
|
-
var audio = document.getElementById("audioInput");
|
|
95
|
-
var deviceInList = false;
|
|
96
|
-
for (var i = 0; i < audio.options.length; i++) {
|
|
97
|
-
if (audio.options[i].value === device.id) {
|
|
98
|
-
deviceInList = true;
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (!deviceInList) {
|
|
103
|
-
var option = document.createElement("option");
|
|
104
|
-
option.text = device.label || device.id;
|
|
105
|
-
option.value = device.id;
|
|
106
|
-
audio.appendChild(option);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
list.video.forEach(function (device) {
|
|
110
|
-
console.log(device);
|
|
111
|
-
var video = document.getElementById("videoInput");
|
|
112
|
-
var deviceInList = false;
|
|
113
|
-
for (var i = 0; i < video.options.length; i++) {
|
|
114
|
-
if (video.options[i].value === device.id) {
|
|
115
|
-
deviceInList = true;
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (!deviceInList) {
|
|
120
|
-
var option = document.createElement("option");
|
|
121
|
-
option.text = device.label || device.id;
|
|
122
|
-
option.value = device.id;
|
|
123
|
-
if (option.text.toLowerCase().indexOf("back") >= 0 && video.children.length > 0) {
|
|
124
|
-
video.insertBefore(option, video.children[0]);
|
|
125
|
-
} else {
|
|
126
|
-
video.appendChild(option);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
$("#url").val(setURL() + "/" + createUUID(8));
|
|
131
|
-
//set initial button callback
|
|
132
|
-
onDisconnected();
|
|
133
|
-
if (list.audio.length === 0) {
|
|
134
|
-
$("#sendAudio").prop('checked', false).prop('disabled', true);
|
|
135
|
-
}
|
|
136
|
-
if (list.video.length === 0) {
|
|
137
|
-
$("#sendVideo").prop('checked', false).prop('disabled', true);
|
|
138
|
-
}
|
|
139
|
-
}).catch(function (error) {
|
|
140
|
-
$("#notifyFlash").text("Failed to get media devices");
|
|
141
|
-
});
|
|
142
|
-
|
|
143
106
|
if (Browser.isiOS() && Browser.isSafariWebRTC()) {
|
|
144
107
|
document.addEventListener('visibilitychange', () => {
|
|
145
108
|
onVisibilityChanged();
|
|
@@ -150,8 +113,43 @@ function init_page() {
|
|
|
150
113
|
var streamName = createUUID(4);
|
|
151
114
|
$("#publishStream").val(streamName);
|
|
152
115
|
$("#playStream").val(streamName);
|
|
153
|
-
|
|
154
116
|
readyControls();
|
|
117
|
+
onDisconnected();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const addDeviceToSelect = function (devices, selectId) {
|
|
121
|
+
devices.forEach(function (device) {
|
|
122
|
+
let select = document.getElementById(selectId);
|
|
123
|
+
let deviceInList = false;
|
|
124
|
+
for (let i = 0; i < select.options.length; i++) {
|
|
125
|
+
if (select.options[i].value === device.id) {
|
|
126
|
+
deviceInList = true;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (!deviceInList) {
|
|
131
|
+
let option = document.createElement("option");
|
|
132
|
+
option.text = device.label || device.id;
|
|
133
|
+
option.value = device.id;
|
|
134
|
+
if (selectId === "videoInput") {
|
|
135
|
+
if (option.text.toLowerCase().indexOf("back") >= 0 && select.children.length > 0) {
|
|
136
|
+
select.insertBefore(option, select.children[0]);
|
|
137
|
+
} else {
|
|
138
|
+
select.appendChild(option);
|
|
139
|
+
}
|
|
140
|
+
} else if (selectId.startsWith("audio")) {
|
|
141
|
+
select.appendChild(option);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const setSwitchableControls = function (devices, inputId, sendId) {
|
|
148
|
+
if (devices && devices.length > 0) {
|
|
149
|
+
addDeviceToSelect(devices, inputId);
|
|
150
|
+
} else {
|
|
151
|
+
$("#" + sendId).prop('checked', false).prop('disabled', true);
|
|
152
|
+
}
|
|
155
153
|
}
|
|
156
154
|
|
|
157
155
|
function onStopped() {
|
|
@@ -224,15 +222,17 @@ function onPublishing(stream) {
|
|
|
224
222
|
$(this).prop('disabled', true);
|
|
225
223
|
stream.stop();
|
|
226
224
|
}).prop('disabled', false);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
225
|
+
if(switchCamEnabled) {
|
|
226
|
+
$("#switchBtn").text("Switch").off('click').click(function () {
|
|
227
|
+
stream.switchCam().then(function(id) {
|
|
228
|
+
console.log("Switched by button to camera " + id);
|
|
229
|
+
$('#videoInput option:selected').prop('selected', false);
|
|
230
|
+
$("#videoInput option[value='"+ id +"']").prop('selected', true);
|
|
231
|
+
}).catch(function(e) {
|
|
232
|
+
console.log("Error " + e);
|
|
233
|
+
});
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
236
|
$("#switchMicBtn").click(function (){
|
|
237
237
|
stream.switchMic().then(function(id) {
|
|
238
238
|
$('#audioInput option:selected').prop('selected', false);
|
|
@@ -489,7 +489,6 @@ function publish() {
|
|
|
489
489
|
publishStream = session.createStream({
|
|
490
490
|
name: streamName,
|
|
491
491
|
display: localVideo,
|
|
492
|
-
cacheLocalResources: true,
|
|
493
492
|
constraints: constraints,
|
|
494
493
|
mediaConnectionConstraints: mediaConnectionConstraints,
|
|
495
494
|
sdpHook: rewriteSdp,
|
|
@@ -710,7 +709,9 @@ function switchToScreen() {
|
|
|
710
709
|
$('#videoInput').prop('disabled', true);
|
|
711
710
|
publishStream.switchToScreen($('#mediaSource').val(), true).catch(function () {
|
|
712
711
|
$("#screenShareToggle").removeAttr("checked");
|
|
713
|
-
|
|
712
|
+
if (switchCamEnabled) {
|
|
713
|
+
$('#switchBtn').prop('disabled', false);
|
|
714
|
+
}
|
|
714
715
|
$('#videoInput').prop('disabled', false);
|
|
715
716
|
});
|
|
716
717
|
}
|
|
@@ -719,7 +720,9 @@ function switchToScreen() {
|
|
|
719
720
|
function switchToCam() {
|
|
720
721
|
if (publishStream) {
|
|
721
722
|
publishStream.switchToCam();
|
|
722
|
-
|
|
723
|
+
if (switchCamEnabled) {
|
|
724
|
+
$('#switchBtn').prop('disabled', false);
|
|
725
|
+
}
|
|
723
726
|
$('#videoInput').prop('disabled', false);
|
|
724
727
|
}
|
|
725
728
|
}
|