Skip to content

Commit

Permalink
feat: Create Waveform component
Browse files Browse the repository at this point in the history
see: #3
  • Loading branch information
sujinleeme committed Jul 22, 2018
1 parent 97b62b9 commit fd2fe1d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const AsyncNoMatch = importedComponent(() =>
})

const Upload = importedComponent(() =>
import(/* webpackChunkName:'NoMatch' */ "./pages/Upload"), {
import(/* webpackChunkName:'NoMatch' */ "./pages/UploadPage"), {
LoadingComponent: Loading
})

Expand Down
43 changes: 43 additions & 0 deletions src/components/Waveform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from "react"
import Wavesurfer from "react-wavesurfer"

class Waveform extends React.Component {
constructor(props) {
super(props)

this.state = {
playing: false,
pos: 0
}
this.handleTogglePlay = this.handleTogglePlay.bind(this)
this.handlePosChange = this.handlePosChange.bind(this)
}

handleTogglePlay() {
this.setState({
playing: !this.state.playing
})
}

handlePosChange(e) {
this.setState({
pos: e.originalArgs[0],
playing: true
})
}

render() {
return (
<div>
<Wavesurfer
audioFile={ "https://ia902606.us.archive.org/35/items/shortpoetry_047_librivox/song_cjrg_teasdale_64kb.mp3" }
pos={ this.state.pos }
onPosChange={ this.handlePosChange }
playing={ this.state.playing }
/>
</div>
)
}
}

export default Waveform
1 change: 0 additions & 1 deletion src/pages/UploadPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react"
import { Link } from "react-router-dom"
import Layout from "../components/Layout"
import AudioFileDropZone from "../components/AudioFileDropZone"
import Waveform from '../components/Waveform'
Expand Down

0 comments on commit fd2fe1d

Please sign in to comment.