summaryrefslogtreecommitdiff
path: root/background.js
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2020-04-15 16:58:12 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2020-04-15 17:00:19 +0200
commit19dd4d3890eb2f840e26e0f6eab33c72a7af7c82 (patch)
treeb8ff6720d5618ea27e00606b63696cdeb24f2bd7 /background.js
parent5a277af641a996898439ad4927041d21d78165fe (diff)
downloadbbb-recorder-master.tar.gz
bbb-recorder-master.zip
Remove live server, conversion and xvfbHEADmaster
Diffstat (limited to 'background.js')
-rw-r--r--background.js66
1 files changed, 6 insertions, 60 deletions
diff --git a/background.js b/background.js
index 5895f19..5786847 100644
--- a/background.js
+++ b/background.js
@@ -2,37 +2,21 @@
let recorder = null;
let filename = null;
-let ws;
-let liveSteam = false;
-let ffmpegServer;
-let doDownload = true;
chrome.runtime.onConnect.addListener(port => {
-
port.onMessage.addListener(msg => {
- console.log(msg);
+ console.log('background script received message', msg);
switch (msg.type) {
-
case 'SET_EXPORT_PATH':
filename = msg.filename
break
- case 'FFMPEG_SERVER':
- ffmpegServer = msg.ffmpegServer
- startWebsock();
- break
-
case 'REC_STOP':
- doDownload = true;
recorder.stop()
break
case 'REC_START':
- if (liveSteam) {
- recorder.start(1000);
- } else {
- recorder.start();
- }
+ recorder.start();
break
case 'REC_CLIENT_PLAY':
@@ -65,42 +49,24 @@ chrome.runtime.onConnect.addListener(port => {
recorder = new MediaRecorder(stream, {
videoBitsPerSecond: 2500000,
ignoreMutedMedia: true,
- mimeType: 'video/webm;codecs=h264'
+ mimeType: 'video/webm'
});
recorder.ondataavailable = function (event) {
if (event.data.size > 0) {
chunks.push(event.data);
- if (liveSteam) {
- ws.send(event.data);
- }
}
};
recorder.onstop = function () {
- if (liveSteam) {
- ws.close();
- }
-
- if(!doDownload){
- chunks = [];
- return;
- }
-
var superBuffer = new Blob(chunks, {
type: 'video/webm'
});
var url = URL.createObjectURL(superBuffer);
- // var a = document.createElement('a');
- // document.body.appendChild(a);
- // a.style = 'display: none';
- // a.href = url;
- // a.download = 'test.webm';
- // a.click();
chrome.downloads.download({
- url: url,
- filename: filename
+ url,
+ filename,
}, () => {
});
}
@@ -113,6 +79,7 @@ chrome.runtime.onConnect.addListener(port => {
}
})
+
chrome.downloads.onChanged.addListener(function (delta) {
if (!delta.state || (delta.state.current != 'complete')) {
return;
@@ -122,26 +89,5 @@ chrome.runtime.onConnect.addListener(port => {
}
catch (e) { }
});
-
})
-function startWebsock() {
-
- ws = new WebSocket(ffmpegServer);
- liveSteam = true;
-
- ws.onmessage = function (e) {
- console.log(e.data);
-
- if (e.data == "ffmpegClosed") {
-
- doDownload = false;
- recorder.stop();
-
- setTimeout(function () {
- startWebsock();
- recorder.start(1000);
- }, 500)
- }
- }
-}