Volume slider

This commit is contained in:
James Barnsley
2016-10-17 16:44:02 +13:00
parent 53a4743902
commit 97026753a0
2 changed files with 29 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import FontAwesome from 'react-fontawesome'
import VolumeSlider from './VolumeSlider'
import * as actions from '../services/mopidy/actions'
class Player extends React.Component{
@ -46,7 +47,9 @@ class Player extends React.Component{
{ consumeButton }
{ randomButton }
{ repeatButton }
{ this.props.mopidy.volume }
<VolumeSlider
volume={ this.props.mopidy.volume }
onChange={(volume) => this.props.actions.instruct('playback.setVolume', { volume: volume })} />
</div>
);
}

View File

@ -0,0 +1,25 @@
import React, { PropTypes } from 'react'
import FontAwesome from 'react-fontawesome'
export default class VolumeSlider extends React.Component{
constructor(props) {
super(props);
}
handleChange(e){
this.props.onChange( parseInt(e.target.value) )
}
render(){
return (
<input
type="range"
value={this.props.volume}
min="0"
max="100"
onChange={ (e) => this.handleChange(e) } />
);
}
}