From 35e579c5660a94fb17e72aaabd634a872dde9bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A4=C3=A4s?= Date: Sun, 28 Aug 2016 22:17:56 +0200 Subject: [PATCH 1/5] Add MVP recorder functionality --- demo/demo.js | 24 +++++++++ demo/index.css | 2 +- src/components/song.js | 20 +++++++- src/utils/recorder.js | 112 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 src/utils/recorder.js diff --git a/demo/demo.js b/demo/demo.js index 5a11d49..94d84af 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -19,6 +19,7 @@ export default class Demo extends Component { this.state = { playing: true, + downloadLinkVisible: false, }; this.handleAudioProcess = this.handleAudioProcess.bind(this); @@ -32,12 +33,34 @@ export default class Demo extends Component { playing: !this.state.playing, }); } + + handleRecordStop(blob, fileName) { + this.setState({ + downloadLinkVisible: true, + }, () => { + const url = URL.createObjectURL(blob); + const anchor = this.refs.downloadLink; + anchor.href = url; + anchor.download = new Date().toISOString() + '.wav'; + }); + } + renderDownloadLink() { + if (!this.state.downloadLinkVisible) { + return null; + } + + return ( + Download + ); + } render() { return (
{ this.visualization = c; }} /> + {this.state.downloadLinkVisible && this.renderDownloadLink()}