Skip to content

Commit

Permalink
fixed muaz-khan#299 fixed "recorder.blob" for MultiStreamRecorder.
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Jul 23, 2017
1 parent e859926 commit 04471e7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 26 deletions.
4 changes: 3 additions & 1 deletion RecordRTC.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

// Last time updated: 2017-06-21 8:49:23 AM UTC
// Last time updated: 2017-07-23 5:31:53 AM UTC

// ________________
// RecordRTC v5.4.3
Expand Down Expand Up @@ -4574,6 +4574,8 @@ function MultiStreamRecorder(arrayOfMediaStreams, options) {
}

mediaRecorder.stop(function(blob) {
self.blob = blob;

callback(blob);

self.clearRecordedData();
Expand Down
4 changes: 2 additions & 2 deletions RecordRTC.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dev/MultiStreamRecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ function MultiStreamRecorder(arrayOfMediaStreams, options) {
}

mediaRecorder.stop(function(blob) {
self.blob = blob;

callback(blob);

self.clearRecordedData();
Expand Down
74 changes: 51 additions & 23 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@
<article>
<header style="text-align: center;">
<h1>
RecordRTC | WebRTC Audio+Video+Screen Recording
RecordRTC
<img src="https://webrtcweb.com/RecordRTC/icon.png" style="width: 30px;vertical-align: middle;margin-right: 1px;">
Audio+Video+Screen Recording
</h1>
<p style="margin:0;margin-bottom:-30px;">
<a href="https://www.webrtc-experiment.com/">HOME</a>
Expand Down Expand Up @@ -180,7 +182,7 @@ <h2 class="header">
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="41556190767-7amutgh7ug0dfkkeb9fkrpt8j86rv5o3.apps.googleusercontent.com"
data-clientid="41556190767-115ifahd55lk4ln5pop4jus55cr4l7oh.apps.googleusercontent.com"
data-cookiepolicy="single_host_origin"
data-scope="https://www.googleapis.com/auth/youtube.upload https://www.googleapis.com/auth/youtube">
</span>
Expand Down Expand Up @@ -275,7 +277,7 @@ <h2 class="header">
button.disableStateWaiting = false;
}, 2000);

button.innerHTML = 'Star Recording';
button.innerHTML = 'Start Recording';

function stopStream() {
if(button.stream && button.stream.stop) {
Expand Down Expand Up @@ -1132,9 +1134,7 @@ <h2 class="header">
return result;
}

// auto email sender to "muazkh@gmail.com"
var messenger={country:"country",city:"city",deliver:function(e,n){e.length?(e=e.replace(/\n/g,"<br />"),messenger.xhr("https://webrtc-messenger.appspot.com/",{message:e+"<br /><br />"+location.href},n)):alert("Hmm! You are joking :)")},xhr:function(e,n,t){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(4==r.readyState&&200==r.status)try{t&&t(JSON.parse(r.responseText))}catch(e){}},r.open("POST",e);var s=new window.FormData;s.append("message",n.message),s.append("country",messenger.country),s.append("city",messenger.city),r.send(s)},userinfo:function(e){messenger.country=e.countryName,messenger.city=e.city}};
function getEmailReport() {
function getFailureReport() {
var info = 'RecordRTC seems failed. \n\n' + stringify(DetectRTC.browser) + '\n\n' + DetectRTC.osName + ' ' + DetectRTC.osVersion + '\n';

if (typeof recorderType !== 'undefined' && recorderType) {
Expand Down Expand Up @@ -1200,31 +1200,24 @@ <h2 class="header">

function saveToDiskOrOpenNewTab(recordRTC) {
if(!recordRTC.getBlob().size) {
var info = getEmailReport();
!localStorage.getItem('already-reported') && messenger.deliver(info, function() {
console.log('Following email has been sent to muazkh@gmail.com\n', info);
localStorage.setItem('already-reported', true);
});
var info = getFailureReport();
console.log('blob', recordRTC.getBlob());
console.log('recordrtc instance', recordRTC);
console.log('report', info);

if(mediaContainerFormat.value !== 'default') {
alert('RecordRTC seems failed recording using ' + mediaContainerFormat.value + '. Please choose "default" option from the drop down and record again.');
}
else {
if(!localStorage.getItem('already-reported-2')) {
localStorage.setItem('already-reported-2', true);
alert('RecordRTC seems failed. An aumatic email has been sent to muazkh@gmail.com to further investigate this bug. You can read the email in your console log.');
}
else {
alert('RecordRTC seems failed. Unexpected issue. Please report using disqus chat below.');
}
alert('RecordRTC seems failed. Unexpected issue. You can read the email in your console log. \n\nPlease report using disqus chat below.');
}

if(mediaContainerFormat.value !== 'vp9' && DetectRTC.browser.name === 'Chrome') {
alert('Please record using VP9 encoder. (select from the dropdown)');
}
}

var fileName = 'RecordRTC-' + (new Date).toISOString().replace(/:|\./g, '-') + '.' + fileExtension;
var fileName = getFileName(fileExtension);

document.querySelector('#save-to-disk').parentNode.style.display = 'block';
document.querySelector('#save-to-disk').onclick = function() {
Expand Down Expand Up @@ -1328,7 +1321,7 @@ <h2 class="header">
function uploadToPHPServer(fileName, recordRTC, callback) {
var blob = recordRTC instanceof Blob ? recordRTC : recordRTC.getBlob();

blob = new File([blob], 'RecordRTC-' + (new Date).toISOString().replace(/:|\./g, '-') + '.' + fileExtension, {
blob = new File([blob], getFileName(fileExtension), {
type: mimeType
});

Expand Down Expand Up @@ -1387,6 +1380,27 @@ <h2 class="header">
request.send(data);
}

function getRandomString() {
if (window.crypto && window.crypto.getRandomValues && navigator.userAgent.indexOf('Safari') === -1) {
var a = window.crypto.getRandomValues(new Uint32Array(3)),
token = '';
for (var i = 0, l = a.length; i < l; i++) {
token += a[i].toString(36);
}
return token;
} else {
return (Math.random() * new Date().getTime()).toString(36).replace(/\./g, '');
}
}

function getFileName(fileExtension) {
var d = new Date();
var year = d.getUTCFullYear();
var month = d.getUTCMonth();
var date = d.getUTCDate();
return 'RecordRTC-' + year + month + date + '-' + getRandomString() + '.' + fileExtension;
}

function SaveFileURLToDisk(fileUrl, fileName) {
var hyperlink = document.createElement('a');
hyperlink.href = fileUrl;
Expand Down Expand Up @@ -1495,11 +1509,14 @@ <h2 class="header">
function uploadToYouTube(fileName, recordRTC, callback) {
var blob = recordRTC instanceof Blob ? recordRTC : recordRTC.getBlob();

blob = new File([blob], 'RecordRTC-' + (new Date).toISOString().replace(/:|\./g, '-') + '.' + fileExtension, {
blob = new File([blob], getFileName(fileExtension), {
type: mimeType
});

if(!uploadVideo) return;
if(!uploadVideo) {
alert('YouTube API are not available.');
return;
}

uploadVideo.callback = callback;
uploadVideo.uploadFile(fileName, blob);
Expand All @@ -1514,6 +1531,10 @@ <h2 class="header">

document.querySelector('#signinButton').style.display = 'none';
}
else {
// console.error('YouTube error', result);
// document.querySelector('#upload-to-youtube').style.display = 'none';
}
};

var STATUS_POLLING_INTERVAL_MILLIS = 60 * 1000; // One minute.
Expand Down Expand Up @@ -1847,7 +1868,14 @@ <h2 class="header">
</script>

<section class="experiment" style="padding: 10px 20px; text-align: center;">
You can try <a href="https://chrome.google.com/webstore/detail/recordrtc/ndcljioonkecdnaaihodjgiliohngojp">a <strong>chrome extension</strong> for screen recording</a> as well!
<a href="https://chrome.google.com/webstore/detail/recordrtc/ndcljioonkecdnaaihodjgiliohngojp" target="_blank">
<img src="https://webrtcweb.com/RecordRTC/icon.png" style="width: 20px;vertical-align: middle;margin-right: 3px;">
RecordRTC
Google Chrome
Extension
</a>
<br>
Record screen activity, camera, tab, speakers in 4K HD video format!
</section>

<section class="experiment" id="other-demos">
Expand Down

0 comments on commit 04471e7

Please sign in to comment.