Skip to content

Commit

Permalink
Re-record handler forwards correct mp3 setting to background page
Browse files Browse the repository at this point in the history
  • Loading branch information
killergerbah committed Jan 26, 2024
1 parent 8c29713 commit 326ee57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion extension/src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const cardPublisher = new CardPublisher(settings);
const handlers: CommandHandler[] = [
new VideoHeartbeatHandler(tabRegistry),
new RecordMediaHandler(backgroundPageManager, imageCapturer, cardPublisher, settings),
new RerecordMediaHandler(backgroundPageManager, cardPublisher),
new RerecordMediaHandler(settings, backgroundPageManager, cardPublisher),
new StartRecordingMediaHandler(backgroundPageManager, imageCapturer, cardPublisher),
new StopRecordingMediaHandler(backgroundPageManager, imageCapturer, cardPublisher, settings),
new TakeScreenshotHandler(imageCapturer, cardPublisher),
Expand Down
14 changes: 11 additions & 3 deletions extension/src/handlers/video/rerecord-media-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ import {
} from '@project/common';
import BackgroundPageManager from '../../services/background-page-manager';
import { CardPublisher } from '../../services/card-publisher';
import { SettingsProvider } from '@project/common/settings';

export default class RerecordMediaHandler {
private readonly _settingsProvider: SettingsProvider;
private readonly _audioRecorder: BackgroundPageManager;
private readonly _cardPublisher: CardPublisher;

constructor(audioRecorder: BackgroundPageManager, cardPublisher: CardPublisher) {
constructor(
settingsProvider: SettingsProvider,
audioRecorder: BackgroundPageManager,
cardPublisher: CardPublisher
) {
this._settingsProvider = settingsProvider;
this._audioRecorder = audioRecorder;
this._cardPublisher = cardPublisher;
}
Expand All @@ -32,14 +39,15 @@ export default class RerecordMediaHandler {
const rerecordCommand = command as VideoToExtensionCommand<RerecordMediaMessage>;

try {
const preferMp3 = await this._settingsProvider.getSingle('preferMp3');
const audio: AudioModel = {
base64: await this._audioRecorder.startWithTimeout(
rerecordCommand.message.duration / rerecordCommand.message.playbackRate +
rerecordCommand.message.audioPaddingEnd,
false,
preferMp3,
{ src: rerecordCommand.src, tabId: sender.tab?.id }
),
extension: 'webm',
extension: preferMp3 ? 'mp3' : 'webm',
paddingStart: rerecordCommand.message.audioPaddingStart,
paddingEnd: rerecordCommand.message.audioPaddingEnd,
start: rerecordCommand.message.timestamp,
Expand Down

0 comments on commit 326ee57

Please sign in to comment.