Files
Iris/src/js/components/MiniPlayer.js

73 lines
1.9 KiB
JavaScript
Raw Normal View History

2016-11-04 13:51:17 +13:00
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { Link } from 'react-router'
import FontAwesome from 'react-fontawesome'
import ProgressSlider from './ProgressSlider'
import VolumeControl from './VolumeControl'
import ArtistSentence from './ArtistSentence'
import Thumbnail from './Thumbnail'
import * as mopidyActions from '../services/mopidy/actions'
class MiniPlayer extends React.Component{
constructor(props) {
super(props);
}
renderPlayButton(){
2017-01-06 16:06:31 +13:00
var button = <a className="play" onClick={() => this.props.mopidyActions.play()}><FontAwesome name="play" /> </a>
if( this.props.play_state == 'playing' ){
2017-01-06 16:06:31 +13:00
button = <a className="play" onClick={() => this.props.mopidyActions.pause()}><FontAwesome name="pause" /> </a>
2016-11-04 13:51:17 +13:00
}
return button;
}
render(){
return (
<div className="player mini-player">
2016-11-04 13:51:17 +13:00
<div className="current-track">
2016-11-22 11:10:30 +13:00
<div className="title">{ this.props.current_track ? this.props.current_track.name : <span>-</span> }</div>
{ this.props.current_track ? <ArtistSentence artists={ this.props.current_track.artists } /> : <ArtistSentence /> }
2016-11-04 13:51:17 +13:00
</div>
<div className="controls">
{ this.renderPlayButton() }
2017-01-06 16:06:31 +13:00
<a className="next" onClick={() => this.props.mopidyActions.next()}>
2016-11-04 13:51:17 +13:00
<FontAwesome name="step-forward" />
</a>&nbsp;
<VolumeControl />
</div>
2016-11-22 11:10:30 +13:00
<ProgressSlider />
2016-11-04 13:51:17 +13:00
</div>
);
}
}
/**
* Export our component
*
* We also integrate our global store, using connect()
**/
const mapStateToProps = (state, ownProps) => {
return {
current_track: state.ui.current_track,
play_state: state.mopidy.play_state
}
2016-11-04 13:51:17 +13:00
}
const mapDispatchToProps = (dispatch) => {
return {
mopidyActions: bindActionCreators(mopidyActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(MiniPlayer)