From d3b6511e550f127cb0ee2e61f0e5e8e688241e2b Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Tue, 10 Sep 2024 16:21:07 +0200 Subject: [PATCH] spot: update version, unload offscreen when background is reloaded --- spot/entrypoints/background.ts | 19 ++++++++++--------- spot/entrypoints/offscreen/main.js | 2 +- spot/package.json | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/spot/entrypoints/background.ts b/spot/entrypoints/background.ts index 7805ab721..8e6289c34 100644 --- a/spot/entrypoints/background.ts +++ b/spot/entrypoints/background.ts @@ -3,7 +3,7 @@ import { WebRequest } from "webextension-polyfill"; export default defineBackground(() => { const CHECK_INT = 60 * 1000; const PING_INT = 30 * 1000; - const VER = '1.0.0'; + const VER = '1.0.3'; const messages = { popup: { @@ -1126,15 +1126,16 @@ export default defineBackground(() => { (c: { contextType: string }) => c.contextType === "OFFSCREEN_DOCUMENT", ); - if (!offscreenDocument) { - await browser.offscreen.createDocument({ - url: "offscreen.html", - reasons: ["DISPLAY_MEDIA", "USER_MEDIA", "BLOBS"], - justification: "Recording from chrome.tabCapture API", - }); - } else { - recording = offscreenDocument.documentUrl.endsWith("#recording"); + if (offscreenDocument) { + await browser.offscreen.closeDocument() } + + await browser.offscreen.createDocument({ + url: "offscreen.html", + reasons: ["DISPLAY_MEDIA", "USER_MEDIA", "BLOBS"], + justification: "Recording from chrome.tabCapture API", + }); + return recording; } async function sendToActiveTab(message: { diff --git a/spot/entrypoints/offscreen/main.js b/spot/entrypoints/offscreen/main.js index 948642041..d24162c44 100644 --- a/spot/entrypoints/offscreen/main.js +++ b/spot/entrypoints/offscreen/main.js @@ -112,6 +112,7 @@ class ScreenRecorder { mimeType: this.settings.mimeType, audioBitsPerSecond: this.settings.audioBitsPerSecond, videoBitsPerSecond: this.settings.videoBitsPerSecond, + videoKeyFrameIntervalDuration: 1000, }); this.mRecorder.ondataavailable = this._handleDataAvailable; @@ -296,7 +297,6 @@ class ScreenRecorder { let recorder = new ScreenRecorder(); recorder.init(getRecordingSettings("720p")); - browser.runtime.onMessage.addListener((message, _, respond) => { if (message.target === "offscreen") { if (message.type === "offscr:start-recording") { diff --git a/spot/package.json b/spot/package.json index d256fad64..fb584e659 100644 --- a/spot/package.json +++ b/spot/package.json @@ -2,7 +2,7 @@ "name": "wxt-starter", "description": "manifest.json description", "private": true, - "version": "1.0.2", + "version": "1.0.3", "type": "module", "scripts": { "dev": "wxt",