-
-
Notifications
You must be signed in to change notification settings - Fork 823
Conversation
Can one of the admins verify this patch? |
@matrixbot test this please |
package.json
Outdated
@@ -62,6 +62,7 @@ | |||
"linkifyjs": "^2.1.3", | |||
"lodash": "^4.13.1", | |||
"matrix-js-sdk": "matrix-org/matrix-js-sdk#develop", | |||
"msr": "^1.3.4", |
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 guess this basically switches between getusermedia and web audio which means we get Safari support? I'm a little hesitant to grow the bundle size by another 22KB.
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.
Oh, looks like you still need to call getUserMedia manually, so it won't make it automatically work in Safari.
}); | ||
} else { | ||
try { | ||
const mediaStream = await navigator.mediaDevices.getUserMedia({ |
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.
Should probably check for this and display a "not supported" message rather than just the normal, "failed to start recording".
onRecordClicked = async () => { | ||
if(this.state.recording && this.mediaStream) { | ||
this.recorder.stop(); | ||
window.ConcatenateBlobs(this.blobs, this.blobs[0].type, (blob) => { |
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.
Ew. I dislike this library that pulls in the completely non-commonjs ConcatenateBlobs which just shoves itself on the window object, for one fairly simple function.
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 hate it too, but used it for a quick first version. I'll get rid of it.
if(this.state.recording && this.mediaStream) { | ||
this.recorder.stop(); | ||
window.ConcatenateBlobs(this.blobs, this.blobs[0].type, (blob) => { | ||
console.log(blob); |
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.
Probably don't want to leave this in
onUserMediaSuccess = (mediaStream: MediaStream) => { | ||
this.mediaStream = mediaStream; | ||
this.recorder = new MediaStreamRecorder(this.mediaStream); | ||
this.recorder.recorderType = class extends MediaStreamRecorder.StereoAudioRecorder { |
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.
If this were a named class you could call it MonoAudioRecorder which might make it more obvious what's going on.
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.
Won't need this once that library's gone.
render() { | ||
const TintableSvg = sdk.getComponent("elements.TintableSvg"); | ||
return ( | ||
<div key="controls_ptt" className="mx_MessageComposer_voicecall" |
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.
This should be an AccessibleButton nowadays
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.
Oh. I'll check for other places where it's used -- MessageComposerInput itself does not seem to have been updated.
return ( | ||
<span className="mx_MAudioBody"> | ||
<audio src={contentUrl} controls /> | ||
<audio src={contentUrl} controls autoPlay={shouldAutoPlay} /> |
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 don't think we can allow auto-playing audio globally: there's too much scope for abuse. This would also presumably play all files as you scrolled past them in the backlog.
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.
True, but I'd prefer to keep this simple and iterate on the logic rather than have this PR stuck forever (given the demand.)
What I had in mind:
- Only autoplay if the current user has also sent a PTT message in the same room (so you need to send one first to have others' messages autoplay to you)
- Play automatically when you receive a message (and the above condition is satisfied)
- Queue up newer messages as they come in, if there's something already playing
(this can't work with the autocomplete attribute though)
Also, while I'm currently reusing the microphone icon, it might be worth considering if we want to change it.
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.
This would also presumably play all files as you scrolled past them in the backlog
Wouldn't this also play sounds as they get rendered. So when I log in, or switch rooms? That sounds quite terrifying.
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.
Perhaps MAY autoplay?
Generally looking nice though, lots of people asking for this feature! Unsure why babel dislikes your flow syntax. |
bded3f4
to
f85bf00
Compare
Also, some usability enhancements
import Modal from '../../../Modal'; | ||
import ErrorDialog from '../dialogs/ErrorDialog'; | ||
|
||
export default class AudioRecorder extends React.Component { |
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.
4 space indents please, for consistency with the rest of the project
if(!navigator.mediaDevices || !MediaRecorder) { | ||
Modal.createDialog(ErrorDialog, { | ||
description: `Sorry, but the features required for push | ||
to talk messages are not supported by your browser`, |
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 ErrorDialog requires title, button and focus: https://github.com/matrix-org/matrix-react-sdk/blob/master/src/components/views/dialogs/ErrorDialog.js#L33
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.
But it also has defaults for those properties.
onUserMediaSuccess = (mediaStream: MediaStream) => { | ||
this.mediaStream = mediaStream; | ||
|
||
this.mediaRecorder = new MediaRecorder(mediaStream); |
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.
Leaving out the options parameter, in particular mimeType
, seems unwise, given the default is likely to vary between browsers. What format are we expecting here? Bear in mind we'll need to spec this so it can be implemented cross-client, we'll need to nail down what audio formats clients should expect.
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.
There is the option to check for supported mimeTypes: MediaRecorder.isTypeSupported(). Expected is "audio/webm;codecs=opus" for Chrome and "audio/ogg;codecs=opus" for Firefox. (Keep in mind that Safari doesn't support MediaRecorder.) Seems like Firefox can only record ogg audio and Chrome only WebM audio (see https://stackoverflow.com/questions/35466078/specifying-codecs-with-mediarecorder). Both browser can play both file types though, so that's not a problem.
|
||
onMediaRecorderStop = () => { | ||
// Chrome gives us video/webm even though we've requested audio | ||
// for some reason. The data's still just audio though. |
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.
It might be more sensible if given a mimeType in the MediaRecorder constructor
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.
Seems like Chrome only supports recording WebM, see https://stackoverflow.com/questions/41739837/all-mime-types-supported-by-mediarecorder-in-firefox-and-chrome and links in the answer. Is that important?
const AccessibleButton = sdk.getComponent("elements.AccessibleButton"); | ||
|
||
const className = classNames('mx_MessageComposer_ptt', { | ||
'mx_MessageComposer_ptt--recording': this.state.recording, |
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.
what's the --
syntax?
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.
a habit I got from using getbem.com on some of my projects but will happily get rid of if it's an issue
Which is why this was commented out later.
…On Saturday 18 February 2017 06:57 PM, Will Hunt wrote:
***@***.**** commented on this pull request.
------------------------------------------------------------------------
In src/components/views/messages/MAudioBody.js
<#690 (comment)>:
> return (
<span className="mx_MAudioBody">
- <audio src={contentUrl} controls />
+ <audio src={contentUrl} controls autoPlay={shouldAutoPlay} />
This would also presumably play all files as you scrolled past
them in the backlog
Wouldn't this /also/ play sounds as they get rendered. So when I log
in, or switch rooms? That sounds quite terrifying.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#690 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOlRIuQHBlf92kML9zcS9h4TISB9nPOks5rdvHMgaJpZM4L-K2z>.
--
Regards,
Aviral Dasgupta
|
@aviraldg Apologies, GH wasn't doing a very good job of hiding old code :/ |
@aviraldg Have you stopped developing this feature? |
The basic feature works as-is, but is blocked on speccing the allowed
formats (something I haven't had time to do yet.) If you are interested in
seeing this merged, discussing that with the team and proposing a change to
the spec for it would be a good start.
On Thu, May 4, 2017 at 5:56 PM dtygel ***@***.***> wrote:
@aviraldg <https://github.com/aviraldg> Have you stoppped developping
this feature?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#690 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOlRCu8WACqo_-MnrTCLZ3KEADukHgyks5r2cPQgaJpZM4L-K2z>
.
--
Regards,
Aviral Dasgupta
|
As a note, the last time I checked (around the beginning of 2017), format support with the MediaRecorder API on different browsers varies significantly. Chrome would produce opus/webm and Firefox opus/ogg. I think there were issues with playback too as well as the MediaRecorder API implementations not always giving the errors they were supposed to meaning that you had to test, verify and tip-toe around how the browsers actually behaved. I would definitely expect the situation to have improved but I'm not certain of it. Testing would be needed. 😄 |
What does telegram web and whatsapp web use for recording and reproducing audio? It seems to work without issues... |
Where do you discuss things with the team? I did some research and suggest the Opus codec. It's state of the art and freely licensed. Chrome and Firefox support it, but Safari doesn't. Is that an issue? Chrome records WebM files and Firefox .ogg files, but both browsers can play both formats. What more information is required? |
@WorldCodeCentral , discussions on riot development happen in riot-dev room: https://riot.im/app/#/room/#riot-dev:matrix.org |
Thanks for making this contribution a while back. Since the code base has changed since this was opened, it no longer applies cleanly, and I don't think there's a need to keep it open in this state, as we can always find the code here again if needed. If you are still interested in pursuing this feature, please discuss with us in #riot-dev:matrix.org to find a good approach forward. |
No description provided.