Commit 3f8abeb5 by yuananting

fix:录音bug

parent a9eec6b0
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-03-18 10:01:28 * @Date: 2020-03-18 10:01:28
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-03-22 16:59:29 * @LastEditTime: 2021-03-22 17:24:38
* @Description: 录音组件 * @Description: 录音组件
*/ */
...@@ -118,6 +118,9 @@ class XMRecord extends Component { ...@@ -118,6 +118,9 @@ class XMRecord extends Component {
}; };
handleFinishRecord = () => { handleFinishRecord = () => {
if (this.mMediaRecorder) {
this.mMediaRecorder.stop();
}
const blob = this.mMediaRecorder.upload(); const blob = this.mMediaRecorder.upload();
UploadOss.uploadBlobToOSS(blob, window.random_string(16) + ".wav").then( UploadOss.uploadBlobToOSS(blob, window.random_string(16) + ".wav").then(
(mp3URL) => { (mp3URL) => {
...@@ -128,9 +131,6 @@ class XMRecord extends Component { ...@@ -128,9 +131,6 @@ class XMRecord extends Component {
isFinished: true, isFinished: true,
}); });
window.clearInterval(this.timer); window.clearInterval(this.timer);
if (this.mMediaRecorder) {
this.mMediaRecorder.stop();
}
} }
); );
}; };
...@@ -147,6 +147,9 @@ class XMRecord extends Component { ...@@ -147,6 +147,9 @@ class XMRecord extends Component {
}; };
handleCancel = () => { handleCancel = () => {
if (this.mMediaRecorder) {
this.mMediaRecorder.stop();
}
window.clearInterval(this.timer); window.clearInterval(this.timer);
this.setState( this.setState(
{ {
...@@ -155,9 +158,6 @@ class XMRecord extends Component { ...@@ -155,9 +158,6 @@ class XMRecord extends Component {
}, },
() => { () => {
this.props.onCancel(); this.props.onCancel();
if (this.mMediaRecorder) {
this.mMediaRecorder.stop();
}
} }
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment