This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 824
Labs feature: Early implementation of voice messages #5769
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
097c2d8
Add labs flag for voice messages
turt2live be2e30d
Add an early voice recorder utility class
turt2live b5d32d9
Wire up a simple record button
turt2live dafa878
Fix comments
turt2live 9aa5348
Show a stop button to stop the recording
turt2live 1dc2427
Remove test function
turt2live f0d5edb
Render voice messages as audio messages for now
turt2live 6c566cd
Remove debugging
turt2live 51dca8d
Fix positioning of stop square
turt2live 69f90ee
Label labs flag as in development
turt2live c7b72bc
Appease the linter
turt2live 0f09eb3
Add more notes
turt2live 207ba11
Tweak a bunch of settings
turt2live e352ed1
Run audio through the Web Audio API instead
turt2live 090cf28
Appease the linter
turt2live b7e6532
Rename function
turt2live c9938ff
Adjust settings/docs for encoder
turt2live d929d48
Clean up promises
turt2live File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright 2021 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
.mx_VoiceRecordComposerTile_stop { | ||
// 28px plus a 2px border makes this a 32px square (as intended) | ||
width: 28px; | ||
height: 28px; | ||
border: 2px solid $voice-record-stop-border-color; | ||
border-radius: 32px; | ||
margin-right: 16px; // between us and the send button | ||
position: relative; | ||
|
||
&::after { | ||
content: ''; | ||
width: 14px; | ||
height: 14px; | ||
position: absolute; | ||
top: 7px; | ||
left: 7px; | ||
border-radius: 2px; | ||
background-color: $voice-record-stop-symbol-color; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
Copyright 2021 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton"; | ||
import {_t} from "../../../languageHandler"; | ||
import React from "react"; | ||
import {VoiceRecorder} from "../../../voice/VoiceRecorder"; | ||
import {Room} from "matrix-js-sdk/src/models/room"; | ||
import {MatrixClientPeg} from "../../../MatrixClientPeg"; | ||
import classNames from "classnames"; | ||
|
||
interface IProps { | ||
room: Room; | ||
onRecording: (haveRecording: boolean) => void; | ||
} | ||
|
||
interface IState { | ||
recorder?: VoiceRecorder; | ||
} | ||
|
||
export default class VoiceRecordComposerTile extends React.PureComponent<IProps, IState> { | ||
public constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
recorder: null, // not recording by default | ||
}; | ||
} | ||
|
||
private onStartStopVoiceMessage = async () => { | ||
// TODO: @@ TravisR: We do not want to auto-send on stop. | ||
if (this.state.recorder) { | ||
await this.state.recorder.stop(); | ||
const mxc = await this.state.recorder.upload(); | ||
MatrixClientPeg.get().sendMessage(this.props.room.roomId, { | ||
body: "Voice message", | ||
msgtype: "org.matrix.msc2516.voice", | ||
url: mxc, | ||
}); | ||
this.setState({recorder: null}); | ||
this.props.onRecording(false); | ||
return; | ||
} | ||
const recorder = new VoiceRecorder(MatrixClientPeg.get()); | ||
await recorder.start(); | ||
this.props.onRecording(true); | ||
// TODO: @@ TravisR: Run through EQ component | ||
// recorder.frequencyData.onUpdate((freq) => { | ||
// console.log('@@ UPDATE', freq); | ||
// }); | ||
this.setState({recorder}); | ||
}; | ||
|
||
public render() { | ||
const classes = classNames({ | ||
'mx_MessageComposer_button': !this.state.recorder, | ||
'mx_MessageComposer_voiceMessage': !this.state.recorder, | ||
'mx_VoiceRecordComposerTile_stop': !!this.state.recorder, | ||
}); | ||
|
||
let tooltip = _t("Record a voice message"); | ||
if (!!this.state.recorder) { | ||
// TODO: @@ TravisR: Change to match behaviour | ||
tooltip = _t("Stop & send recording"); | ||
} | ||
|
||
return ( | ||
<AccessibleTooltipButton | ||
className={classes} | ||
onClick={this.onStartStopVoiceMessage} | ||
title={tooltip} | ||
/> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is our nominally preferred way of doing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it? I don't recall this, and haven't done this conversion in years
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair enough - I think this might be from kegan days. I have no preference personally.