Skip to content

Commit a71ee26

Browse files

File tree

139 files changed

+27085
-59071
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+27085
-59071
lines changed

ConcatenateBlobs/ConcatenateBlobs.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Last time updated at Sep 15, 2014, 08:32:23
1+
// Last time updated at Nov 18, 2014, 08:32:23
22

33
// Latest file can be found here: https://cdn.webrtc-experiment.com/ConcatenateBlobs.js
44

@@ -39,16 +39,17 @@
3939
buffers.forEach(function(buffer) {
4040
byteLength += buffer.byteLength;
4141
});
42+
4243
var tmp = new Uint16Array(byteLength);
43-
4444
var lastOffset = 0;
4545
buffers.forEach(function(buffer) {
4646
// BYTES_PER_ELEMENT == 2 for Uint16Array
47-
if (buffer.byteLength % 2 != 0) {
48-
delete buffer[byteLength - 1];
47+
var reusableByteLength = buffer.byteLength;
48+
if (reusableByteLength % 2 != 0) {
49+
buffer = buffer.slice(0, reusableByteLength - 1)
4950
}
5051
tmp.set(new Uint16Array(buffer), lastOffset);
51-
lastOffset += buffer.byteLength;
52+
lastOffset += reusableByteLength;
5253
});
5354

5455
var blob = new Blob([tmp.buffer], {

ConcatenateBlobs/README.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ To use it:
2121

2222
```
2323
https://cdn.webrtc-experiment.com/ConcatenateBlobs.js
24+
25+
// or
26+
https://www.webrtc-experiment.com/ConcatenateBlobs.js
2427
```
2528

2629
## 2. Use it
@@ -38,13 +41,7 @@ ConcatenateBlobs([arrayOfBlobs], 'audio/wav', function(resultingBlob) {
3841

3942
## Credits
4043

41-
[Muaz Khan](https://github.com/muaz-khan):
42-
43-
1. Personal Webpage: http://www.muazkhan.com
44-
45-
3. Twitter: https://twitter.com/muazkh and https://twitter.com/WebRTCWeb
46-
4. Google+: https://plus.google.com/+WebRTC-Experiment
47-
5. Facebook: https://www.facebook.com/WebRTC
44+
* [Muaz Khan](http://www.MuazKhan.com/)
4845

4946
## License
5047

ConcatenateBlobs/index.html

+45-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ <h1>ConcatenateBlobs | JavaScript - <a href="https://github.com/muaz-khan/Concat
77
</blockquote>
88

99
<style>
10-
button {
10+
button, select {
1111
font-family: Myriad, Arial, Verdana;
1212
font-weight: normal;
1313
border-top-left-radius: 3px;
@@ -23,10 +23,16 @@ <h1>ConcatenateBlobs | JavaScript - <a href="https://github.com/muaz-khan/Concat
2323
background: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0.05, rgb(241, 241, 241)), to(rgb(230, 230, 230)));
2424
font-size: 20px;
2525
border: 1px solid red;
26+
outline:none;
2627
}
27-
button[disabled] {
28-
background: rgba(216, 205, 205, 0.2);
29-
border: 1px solid rgb(233, 224, 224);
28+
button:active, button:focus, select:active {
29+
background: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(5%, rgb(221, 221, 221)), to(rgb(250, 250, 250)));
30+
border: 1px solid rgb(142, 142, 142);
31+
}
32+
button[disabled], select[disabled] {
33+
background: rgb(249, 249, 249);
34+
border: 1px solid rgb(218, 207, 207);
35+
color: rgb(197, 189, 189);
3036
}
3137
blockquote {
3238
font-size: 20px;
@@ -52,13 +58,17 @@ <h1>ConcatenateBlobs | JavaScript - <a href="https://github.com/muaz-khan/Concat
5258
</p>
5359
<hr />
5460

55-
<audio controls></audio>
61+
<select>
62+
<option>Audio</option>
63+
<option>Video</option>
64+
</select><br><br>
65+
<audio controls data-type="audio/wav"></audio>
5666

5767
<script src="https://cdn.webrtc-experiment.com/RecordRTC.js" autoplay> </script>
5868
<script src="https://cdn.webrtc-experiment.com/ConcatenateBlobs.js" autoplay> </script>
5969

6070
<script>
61-
var audio = document.querySelector('audio');
71+
var mediaElement = document.querySelector('audio');
6272

6373
var recordRTC;
6474
var allBlobs = [];
@@ -68,14 +78,18 @@ <h1>ConcatenateBlobs | JavaScript - <a href="https://github.com/muaz-khan/Concat
6878
document.querySelector('#concatenateBlobs').disabled = true;
6979

7080
navigator.getUserMedia({
71-
audio: true
81+
audio: mediaElement.getAttribute('data-type') == 'audio/wav',
82+
video: mediaElement.getAttribute('data-type') == 'video/webm'
7283
}, function(stream) {
7384
localMediaStream = stream;
7485

75-
audio.src = URL.createObjectURL(stream);
76-
audio.play();
86+
mediaElement.src = URL.createObjectURL(stream);
87+
mediaElement.play();
7788

78-
recordRTC = RecordRTC(stream);
89+
recordRTC = RecordRTC(stream, {
90+
type: mediaElement.getAttribute('data-type') == 'audio/wav' ? 'audio' : 'video',
91+
video: mediaElement
92+
});
7993
recordRTC.startRecording();
8094

8195
document.querySelector('#stopRecording').disabled = false;
@@ -108,11 +122,11 @@ <h1>ConcatenateBlobs | JavaScript - <a href="https://github.com/muaz-khan/Concat
108122

109123
var parent = output.parentNode;
110124
parent.innerHTML = 'Concatenating ' + allBlobs.length + ' blobs.';
111-
ConcatenateBlobs(allBlobs, 'audio/wav', function(resultingBlob) {
125+
ConcatenateBlobs(allBlobs, mediaElement.getAttribute('data-type'), function(resultingBlob) {
112126
parent.innerHTML = 'Concatenated. Resulting blob size: <span>' + bytesToSize(resultingBlob.size) + '</span>. Playing-back locally in &lt;audio&gt; tag.';
113127

114-
audio.src = URL.createObjectURL(resultingBlob);
115-
audio.play();
128+
mediaElement.src = URL.createObjectURL(resultingBlob);
129+
mediaElement.play();
116130
});
117131
};
118132

@@ -126,6 +140,24 @@ <h1>ConcatenateBlobs | JavaScript - <a href="https://github.com/muaz-khan/Concat
126140
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(k)), 10);
127141
return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
128142
}
143+
144+
document.querySelector('select').onchange = function() {
145+
if(this.value == 'Video') {
146+
var video = document.createElement('video');
147+
video.setAttribute('data-type', 'video/webm');
148+
video.setAttribute('controls', 'true');
149+
mediaElement.parentNode.replaceChild(video, mediaElement);
150+
mediaElement = video;
151+
}
152+
153+
if(this.value == 'Audio') {
154+
var video = document.createElement('audio');
155+
video.setAttribute('data-type', 'audio/wav');
156+
video.setAttribute('controls', 'true');
157+
mediaElement.parentNode.replaceChild(video, mediaElement);
158+
mediaElement = video;
159+
}
160+
};
129161
</script>
130162

131163
<h2>How to use?</h2>

ConcatenateBlobs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "concatenateblobs",
33
"preferGlobal": true,
4-
"version": "1.0.0",
4+
"version": "1.0.2",
55
"author": {
66
"name": "Muaz Khan",
77
"email": "[email protected]",
@@ -42,6 +42,6 @@
4242
"email": "[email protected]"
4343
},
4444
"homepage": "https://www.webrtc-experiment.com/ConcatenateBlobs/",
45-
"_id": "concatenateblobs@1.0.0",
45+
"_id": "concatenateblobs@",
4646
"_from": "concatenateblobs@"
4747
}

DataChannel/DataChannel.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Last time updated at May 21, 2014, 08:32:23
1+
// Last time updated at Nov 21, 2014, 08:32:23
22

33
// Muaz Khan - www.MuazKhan.com
44
// MIT License - www.WebRTC-Experiment.com/licence
@@ -172,7 +172,7 @@
172172

173173
prepareInit(function () {
174174
init();
175-
if (IsDataChannelSupported) dataConnector.createRoom();
175+
if (IsDataChannelSupported) dataConnector.createRoom(_channel);
176176
});
177177
};
178178

@@ -536,7 +536,6 @@
536536
var defaultSocket = root.openSignalingChannel({
537537
onmessage: function (response) {
538538
if (response.userToken == self.userToken) return;
539-
540539
if (isGetNewRoom && response.roomToken && response.broadcaster) config.ondatachannel(response);
541540

542541
if (response.newParticipant) onNewParticipant(response.newParticipant);
@@ -558,8 +557,8 @@
558557
});
559558

560559
return {
561-
createRoom: function () {
562-
self.roomToken = uniqueToken();
560+
createRoom: function (roomToken) {
561+
self.roomToken = roomToken || uniqueToken();
563562

564563
isbroadcaster = true;
565564
isGetNewRoom = false;

0 commit comments

Comments
 (0)