Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: improve/media-recorder #26426

Merged
merged 5 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@

&-done,
&-cancel,
&-timer,
&-loading {
&-timer {
display: none;
}

Expand Down Expand Up @@ -205,12 +204,6 @@
}
}

&-loading {
cursor: pointer;

animation: spin 1s linear infinite;
}

&--recording {
.rc-message-box__audio-message-mic,
.rc-message-box__audio-message-loading {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{{> Template.dynamic template=customAction.template data=customAction.data }}
{{ else }}
{{#if canSend}}
{{> messageBoxAudioMessage rid=rid tmid=tmid}}
{{> AudioMessageRecorder rid=rid tmid=tmid }}
<span class="rc-message-box__action-menu js-action-menu" data-desktop aria-haspopup="true" data-qa-id="menu-more-actions">
{{#if actions}}
<span class="rc-message-box__icon">
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/app/ui-message/client/messageBox/messageBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { roomCoordinator } from '../../../../client/lib/rooms/roomCoordinator';
import './messageBoxActions';
import './messageBoxReplyPreview.ts';
import './userActionIndicator.ts';
import './messageBoxAudioMessage.ts';
import './messageBox.html';

type MessageBoxTemplateInstance = Blaze.TemplateInstance<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ messageBox.actions.add('Add_files_from', 'Computer', {
};
});

fileUpload(filesToUpload, $('.js-input-message', messageBox).get(0) as HTMLTextAreaElement | undefined, { rid, tmid });
fileUpload(filesToUpload, $('.js-input-message', messageBox).get(0) as HTMLTextAreaElement, { rid, tmid });
$input.remove();
});

Expand Down

This file was deleted.

173 changes: 0 additions & 173 deletions apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/meteor/app/ui/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export { fileUpload } from './lib/fileUpload';
export { UserAction, USER_ACTIVITIES } from './lib/UserAction';
export { KonchatNotification } from './lib/notification';
export { Login, Button } from './lib/rocket';
export { AudioRecorder } from './lib/recorderjs/audioRecorder';
export { AudioRecorder } from './lib/recorderjs/AudioRecorder';
export { VideoRecorder } from './lib/recorderjs/videoRecorder';
export * from './lib/userPopoverStatus';
2 changes: 1 addition & 1 deletion apps/meteor/app/ui/client/lib/fileUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export type FileUploadProp = SingleOrArray<{
/* @deprecated */
export const fileUpload = async (
f: FileUploadProp,
input: HTMLTextAreaElement | undefined,
input: HTMLInputElement | ArrayLike<HTMLInputElement> | HTMLTextAreaElement,
{
rid,
tmid,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Meteor } from 'meteor/meteor';
import { Emitter } from '@rocket.chat/emitter';

import { settings } from '../../../../settings';
export class AudioEncoder extends Emitter {
private worker: Worker;

class AudioEncoder extends Emitter {
constructor(source, { bufferLen = 4096, numChannels = 1, bitRate = settings.get('Message_Audio_bitRate') || 32 } = {}) {
private scriptNode: ScriptProcessorNode;

constructor(source: MediaStreamAudioSourceNode, { bufferLen = 4096, numChannels = 1, bitRate = 32 } = {}) {
super();

const workerPath = Meteor.absoluteUrl('workers/mp3-encoder/index.js');
Expand All @@ -21,12 +23,7 @@ class AudioEncoder extends Emitter {
},
});

this.scriptNode = (source.context.createScriptProcessor || source.context.createJavaScriptNode).call(
source.context,
bufferLen,
numChannels,
numChannels,
);
this.scriptNode = source.context.createScriptProcessor(bufferLen, numChannels, numChannels);
this.scriptNode.onaudioprocess = this.handleAudioProcess;

source.connect(this.scriptNode);
Expand All @@ -37,7 +34,7 @@ class AudioEncoder extends Emitter {
this.worker.postMessage({ command: 'finish' });
}

handleWorkerMessage = (event) => {
handleWorkerMessage = (event: MessageEvent) => {
switch (event.data.command) {
case 'end': {
// prepend mp3 magic number to the buffer
Expand All @@ -51,7 +48,7 @@ class AudioEncoder extends Emitter {
}
};

handleAudioProcess = (event) => {
handleAudioProcess = (event: AudioProcessingEvent) => {
for (let channel = 0; channel < event.inputBuffer.numberOfChannels; channel++) {
const buffer = event.inputBuffer.getChannelData(channel);
this.worker.postMessage({
Expand All @@ -61,5 +58,3 @@ class AudioEncoder extends Emitter {
}
};
}

export { AudioEncoder };
Loading