forked from muaz-khan/RecordRTC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseeking-workaround.html
116 lines (92 loc) · 3.16 KB
/
seeking-workaround.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<style>
html, body {
margin: 0!important;
padding: 0!important;
text-align: center;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 1em;
}
video {
width: 30%;
border-radius: 5px;
border: 1px solid black;
}
</style>
<title>Seeking Workaround | RecordRTC</title>
<h1>Seeking Workaround for RecordRTC</h1>
<br>
<button id="btn-start-recording">Start Recording</button>
<button id="btn-stop-recording" disabled>Stop Recording</button>
<hr>
<video controls autoplay playsinline></video>
<script src="/RecordRTC.js"></script>
<script src="https://www.webrtc-experiment.com/EBML.js"></script> <!-- ../libs/DBML.js -->
<script>
var video = document.querySelector('video');
function captureStream(callback) {
navigator.mediaDevices.getUserMedia({video:true,audio:true}).then(function(stream) {
callback(stream);
}).catch(function(error) {
console.error(error);
alert('Unable to capture your stream. Please check console logs.\n' + error);
});
}
function stopRecordingCallback() {
video.muted = false;
video.volume = 1;
video.src = video.srcObject = null;
getSeekableBlob(recorder.getBlob(), function(seekableBlob) {
video.src = URL.createObjectURL(seekableBlob);
recorder.stream.stop();
recorder.destroy();
recorder = null;
document.getElementById('btn-start-recording').disabled = false;
invokeSaveAsDialog(seekableBlob, 'seekable-recordrtc.webm');
});
}
var recorder; // globally accessible
document.getElementById('btn-start-recording').onclick = function() {
this.disabled = true;
captureStream(function(stream) {
video.muted = true;
video.volume = 0;
video.srcObject = stream;
recorder = RecordRTC(stream, {
type: 'video'
});
recorder.startRecording();
// release stream on stopRecording
recorder.stream = stream;
document.getElementById('btn-stop-recording').disabled = false;
});
};
document.getElementById('btn-stop-recording').onclick = function() {
this.disabled = true;
recorder.stopRecording(stopRecordingCallback);
};
function addStreamStopListener(stream, callback) {
stream.addEventListener('ended', function() {
callback();
callback = function() {};
}, false);
stream.addEventListener('inactive', function() {
callback();
callback = function() {};
}, false);
stream.getTracks().forEach(function(track) {
track.addEventListener('ended', function() {
callback();
callback = function() {};
}, false);
track.addEventListener('inactive', function() {
callback();
callback = function() {};
}, false);
});
}
</script>
<br><br>
<footer style="margin-top: 20px; text-align: left;">
<small id="send-message"></small>
</footer>
<script src="https://www.webrtc-experiment.com/common.js"></script>