Skip to content

Commit e9ce469

Browse files
committed
Updated MediaRecorder instantation to try VP8 and VP9 options Object and VP8 string options
1 parent c219975 commit e9ce469

File tree

1 file changed

+17
-10
lines changed
  • src/content/getusermedia/record/js

1 file changed

+17
-10
lines changed

src/content/getusermedia/record/js/main.js

+17-10
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var isSecureOrigin = location.protocol === 'https:' ||
4040
location.host === 'localhost';
4141
if (!isSecureOrigin) {
4242
alert('getUserMedia() must be run from a secure origin: HTTPS or localhost.' +
43-
'\n\nChanging protocol to HTTPS');
43+
'\n\nChanging protocol to HTTPS');
4444
location.protocol = 'HTTPS';
4545
}
4646

@@ -80,21 +80,28 @@ function toggleRecording() {
8080
}
8181
}
8282

83+
// The nested try blocks will be simplified when Chrome 47 moves to Stable
8384
function startRecording() {
8485
var options = {mimeType: 'video/vp9'};
86+
recordedBlobs = [];
8587
try {
86-
recordedBlobs = [];
8788
mediaRecorder = new MediaRecorder(window.stream, options);
88-
} catch (e) {
89+
} catch (e0) {
90+
console.log('Unable to create MediaRecorder with options Object: ', e0);
8991
try {
90-
console.log('Unable to create MediaRecorder with options Object: ', e);
91-
options = 'video/vp8'; // Chrome 47
92+
options = {mimeType: 'video/vp9'};
9293
mediaRecorder = new MediaRecorder(window.stream, options);
93-
} catch (exc) {
94-
alert('MediaRecorder is not supported by this browser.\n\n' +
95-
'Try Firefox 29 or later, or Chrome 47 or later, with Enable experimental Web Platform features enabled from chrome://flags.');
96-
console.error('Exception while creating MediaRecorder:', exc);
97-
return;
94+
} catch (e1) {
95+
console.log('Unable to create MediaRecorder with options Object: ', e1);
96+
try {
97+
options = 'video/vp8'; // Chrome 47
98+
mediaRecorder = new MediaRecorder(window.stream, options);
99+
} catch (e2) {
100+
alert('MediaRecorder is not supported by this browser.\n\n' +
101+
'Try Firefox 29 or later, or Chrome 47 or later, with Enable experimental Web Platform features enabled from chrome://flags.');
102+
console.error('Exception while creating MediaRecorder:', e2);
103+
return;
104+
}
98105
}
99106
}
100107
console.log('Created MediaRecorder', mediaRecorder, 'with options', options);

0 commit comments

Comments
 (0)