-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
RecordRTC_Extension.html
75 lines (60 loc) · 2.52 KB
/
RecordRTC_Extension.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<style>
html, body {
margin: 0!important;
padding: 0!important;
}
video {
max-width: 100%;
}
</style>
<title>RecordRTC Google Chrome Extension API</title>
<h1>How to use RecordRTC_Extension? <a href="https://github.com/muaz-khan/Chrome-Extensions/tree/master/screen-recording#call-from-your-own-website">Check API/Documentation</a></h1>
<p>This chrome extension is required: <a href="https://chrome.google.com/webstore/detail/recordrtc/ndcljioonkecdnaaihodjgiliohngojp">Link To Google Chrome Extension</a></p>
<br>
<select id="RecordRTC_Extension_Options">
<option value="0">Screen Only (without audio)</option>
<option value="1">Screen + Microphone</option>
<option value="2">Screen + Speakers</option>
<option value="3">Screen + Microphone + Speakers</option>
<option value="4">Chrome Tab</option>
<option value="5">Chrome Tab (Audio Only)</option>
<option value="6">Full Screen + Camera</option>
<option value="7">Microphone + Camera</option>
<option value="8">Microphone + Speakers</option>
<option value="9">Microphone Only</option>
<option value="10">Speakers Only</option>
</select>
<button id="btn-start-recording">Start Recording</button>
<button id="btn-stop-recording" disabled>Stop Recording</button>
<hr>
<video controls autoplay playsinline></video>
<script>
if(typeof RecordRTC_Extension === 'undefined') {
alert('RecordRTC chrome extension is either disabled or not installed.');
}
// first step
var recorder = new RecordRTC_Extension();
var video = document.querySelector('video');
function stopRecordingCallback(blob) {
video.src = video.srcObject = null;
video.src = URL.createObjectURL(blob);
recorder = null;
}
document.getElementById('btn-start-recording').onclick = function() {
this.disabled = true;
// you can find list-of-options here:
// https://github.com/muaz-khan/Chrome-Extensions/tree/master/screen-recording#getsupoortedformats
var options = recorder.getSupoortedFormats()[document.getElementById('RecordRTC_Extension_Options').value];
// second step
recorder.startRecording(options, function() {
document.getElementById('btn-stop-recording').disabled = false;
});
};
document.getElementById('btn-stop-recording').onclick = function() {
this.disabled = true;
// third and last step
recorder.stopRecording(stopRecordingCallback);
};
</script>
<footer style="margin-top: 20px;"><small id="send-message"></small></footer>
<script src="https://www.webrtc-experiment.com/common.js"></script>