This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5769 from matrix-org/travis/voice-messages/exp
Labs feature: Early implementation of voice messages
- Loading branch information
Showing
18 changed files
with
378 additions
and
6 deletions.
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.