now checking for browser support and permission
This commit is contained in:
parent
75a82aa3c9
commit
838364b6f1
3 changed files with 19 additions and 5 deletions
|
@ -17,8 +17,6 @@ let _stream;
|
||||||
let _mediaRecorder;
|
let _mediaRecorder;
|
||||||
const audioChunks = [];
|
const audioChunks = [];
|
||||||
|
|
||||||
// TODO: Check if supported, check if browser allows
|
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
if (_mediaRecorder) return;
|
if (_mediaRecorder) return;
|
||||||
|
|
||||||
|
@ -77,10 +75,17 @@ function restartRec() {
|
||||||
function VoiceMailRecorder({ fnHowToSubmit }) {
|
function VoiceMailRecorder({ fnHowToSubmit }) {
|
||||||
const [state, setState] = React.useState('Recording');
|
const [state, setState] = React.useState('Recording');
|
||||||
const [timeRecording, setTimeRecording] = React.useState('00:00');
|
const [timeRecording, setTimeRecording] = React.useState('00:00');
|
||||||
|
const [browserHasNoSupport, setBrowserHasNoSupport] = React.useState(!navigator.mediaDevices
|
||||||
|
? 'It seems like your browser is unsupported' : null);
|
||||||
|
|
||||||
async function initiateInitiation() {
|
async function initiateInitiation() {
|
||||||
if (!_mediaRecorder) {
|
if (!_mediaRecorder) {
|
||||||
await init();
|
await init().catch((err) => {
|
||||||
|
console.warn('Recording is disallowed', err);
|
||||||
|
setBrowserHasNoSupport('It seems like you have disallowed Cinny to record your voice ༼ つ ◕_◕ ༽つ');
|
||||||
|
});
|
||||||
|
|
||||||
|
if (browserHasNoSupport) return;
|
||||||
startOrResumeRec();
|
startOrResumeRec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +136,7 @@ function VoiceMailRecorder({ fnHowToSubmit }) {
|
||||||
// fnRequestResult(stopAndSubmit);
|
// fnRequestResult(stopAndSubmit);
|
||||||
initiateInitiation();
|
initiateInitiation();
|
||||||
|
|
||||||
return (
|
const ui = (
|
||||||
<div className="room-attachment">
|
<div className="room-attachment">
|
||||||
<div className="room-attachment__preview">
|
<div className="room-attachment__preview">
|
||||||
<RawIcon src={VolumeFullIC} />
|
<RawIcon src={VolumeFullIC} />
|
||||||
|
@ -151,6 +156,10 @@ function VoiceMailRecorder({ fnHowToSubmit }) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return browserHasNoSupport
|
||||||
|
? <Text variant="b1" className="room-attachment unsupported-info">{browserHasNoSupport}</Text>
|
||||||
|
: ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
VoiceMailRecorder.propTypes = {
|
VoiceMailRecorder.propTypes = {
|
||||||
|
|
|
@ -7,4 +7,8 @@
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
// max-width: ;
|
// max-width: ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.unsupported-info {
|
||||||
|
height: 2em;
|
||||||
}
|
}
|
|
@ -180,8 +180,9 @@ function RoomViewInput({
|
||||||
if (msgBody.trim() === '' && attachmentOrUi === null) return;
|
if (msgBody.trim() === '' && attachmentOrUi === null) return;
|
||||||
sendIsTyping(false);
|
sendIsTyping(false);
|
||||||
|
|
||||||
|
// TODO: Notify user about their mistake
|
||||||
|
if (typeof attachmentOrUi === 'string') return; // Attachment UI is not finished
|
||||||
roomsInput.setMessage(roomId, msgBody);
|
roomsInput.setMessage(roomId, msgBody);
|
||||||
if (typeof attachmentOrUi === 'string') console.log('input is not FINISHED'); // TODO: disallow sending
|
|
||||||
if (attachmentOrUi !== null && typeof attachmentOrUi === 'object') {
|
if (attachmentOrUi !== null && typeof attachmentOrUi === 'object') {
|
||||||
roomsInput.setAttachment(roomId, attachmentOrUi);
|
roomsInput.setAttachment(roomId, attachmentOrUi);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue