import * as React from 'react' import * as ReactDOM from 'react-dom' import * as RecordingAudioEngine from '../src' import Recording from './recording' interface ExampleState { recordings: RecordingAudioEngine.MonoRecording[] maxRecordingTime: number } class Example extends React.Component { constructor(props: any) { super(props) this.state = { recordings: [], maxRecordingTime: 5 } } private handleStartRecording = () => { const { recordings, maxRecordingTime } = this.state RecordingAudioEngine.Recording.startRecording(maxRecordingTime).then( recording => { this.setState({ recordings: [...recordings, recording] }) } ) } private renderStartStop() { return (
) } private renderRecordings() { if (!this.state.recordings) return null const recordings = this.state.recordings.map((recording, i) => ( )) return } private renderMaxTimeout() { return (
Max Recording Length (seconds): this.setState({ maxRecordingTime: parseInt(e.target.value, 10) }) } min={1} type="number" value={this.state.maxRecordingTime} />
) } public render() { return (
{this.renderMaxTimeout()} {this.renderStartStop()} {this.renderRecordings()}
) } } ReactDOM.render(, document.getElementById('example'))