does not work
This commit is contained in:
Generated
+1321
-44
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -2,7 +2,6 @@
|
|||||||
"name": "tinode-webapp",
|
"name": "tinode-webapp",
|
||||||
"description": "Tinode messenger for the web",
|
"description": "Tinode messenger for the web",
|
||||||
"version": "0.20.2",
|
"version": "0.20.2",
|
||||||
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/tinode/example-react-js.git"
|
"url": "https://github.com/tinode/example-react-js.git"
|
||||||
@@ -71,7 +70,8 @@
|
|||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-intl": "^5.20.2",
|
"react-intl": "^5.20.2",
|
||||||
"tinode-sdk": "^0.20.2"
|
"tinode-sdk": "^0.20.2",
|
||||||
|
"ts-ebml": "^2.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.14.5",
|
"@babel/core": "^7.14.5",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import React from 'react';
|
|||||||
import AudioPlayer from './audio-player.jsx';
|
import AudioPlayer from './audio-player.jsx';
|
||||||
// Workaround for https://bugs.chromium.org/p/chromium/issues/detail?id=642012
|
// Workaround for https://bugs.chromium.org/p/chromium/issues/detail?id=642012
|
||||||
// import fixWebmDuration from 'fix-webm-duration';
|
// import fixWebmDuration from 'fix-webm-duration';
|
||||||
|
import * as ebml from 'ts-ebml';
|
||||||
|
|
||||||
import { intArrayToBase64 } from '../lib/blob-helpers.js'
|
import { intArrayToBase64 } from '../lib/blob-helpers.js'
|
||||||
import { secondsToTime } from '../lib/strformat';
|
import { secondsToTime } from '../lib/strformat';
|
||||||
@@ -269,12 +270,38 @@ export default class AudioRecorder extends React.PureComponent {
|
|||||||
// Obtain data in a form sutable for sending or playing back.
|
// Obtain data in a form sutable for sending or playing back.
|
||||||
// If duration is valid, apply fix for Chrome's WebM duration bug.
|
// If duration is valid, apply fix for Chrome's WebM duration bug.
|
||||||
getRecording(mimeType, duration) {
|
getRecording(mimeType, duration) {
|
||||||
let blob = new Blob(this.audioChunks, {type: mimeType || AUDIO_MIME_TYPE});
|
mimeType = mimeType || AUDIO_MIME_TYPE;
|
||||||
|
let blob = new Blob(this.audioChunks, {type: mimeType});
|
||||||
|
return this.tempFixMetadata(blob, mimeType)
|
||||||
|
.then(fixedBlob => { blob = fixedBlob; return fixedBlob.arrayBuffer(); })
|
||||||
|
.then(arrayBuff => this.audioContext.decodeAudioData(arrayBuff))
|
||||||
|
.then(decoded => this.createPreview(decoded))
|
||||||
|
.then(preview => ({url: window.URL.createObjectURL(blob), preview: intArrayToBase64(preview)}));
|
||||||
|
/*
|
||||||
return (duration > 0 ? ysFixWebmDuration(blob, duration, {logger: false}) : Promise.resolve(blob))
|
return (duration > 0 ? ysFixWebmDuration(blob, duration, {logger: false}) : Promise.resolve(blob))
|
||||||
.then(fixedBlob => { blob = fixedBlob; return fixedBlob.arrayBuffer(); })
|
.then(fixedBlob => { blob = fixedBlob; return fixedBlob.arrayBuffer(); })
|
||||||
.then(arrayBuff => this.audioContext.decodeAudioData(arrayBuff))
|
.then(arrayBuff => this.audioContext.decodeAudioData(arrayBuff))
|
||||||
.then(decoded => this.createPreview(decoded))
|
.then(decoded => this.createPreview(decoded))
|
||||||
.then(preview => ({url: window.URL.createObjectURL(blob), preview: intArrayToBase64(preview)}));
|
.then(preview => ({url: window.URL.createObjectURL(blob), preview: intArrayToBase64(preview)}));
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
tempFixMetadata(blob, mimeType) {
|
||||||
|
const decoder = new ebml.Decoder();
|
||||||
|
const reader = new ebml.Reader();
|
||||||
|
reader.logging = true;
|
||||||
|
reader.logGroup = "Raw WebM file";
|
||||||
|
reader.drop_default_duration = false;
|
||||||
|
let webmBuf;
|
||||||
|
blob.arrayBuffer()
|
||||||
|
.then(buf => { webmBuf = buf; return decoder.decode(buf); })
|
||||||
|
.then(elms => {
|
||||||
|
elms.forEach(elm => reader.read(elm))
|
||||||
|
reader.stop();
|
||||||
|
const fixedMetadataBuf = ebml.tools.makeMetadataSeekable(reader.metadatas, reader.duration, reader.cues);
|
||||||
|
const body = webmBuf.slice(reader.metadataSize);
|
||||||
|
return new Blob([fixedMetadataBuf, body], {type: mimeType});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preview must be calculated at the source: Chrome does not allow background AudioContext.
|
// Preview must be calculated at the source: Chrome does not allow background AudioContext.
|
||||||
|
|||||||
+6903
-15
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user