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 ArtistSentence from './ArtistSentence' import Thumbnail from './Thumbnail' import Dater from './Dater' import * as mopidyActions from '../services/mopidy/actions' class FullPlayer extends React.Component{ constructor(props) { super(props); } renderPlayButton(){ var button = this.props.mopidyActions.play()}> if( this.props.play_state == 'playing' ){ button = this.props.mopidyActions.pause()}> } return button; } renderConsumeButton(){ var button = this.props.mopidyActions.instruct('tracklist.setConsume', [true])}> if( this.props.consume ){ button = this.props.mopidyActions.instruct('tracklist.setConsume', [false])}> } return button; } renderRandomButton(){ var button = this.props.mopidyActions.instruct('tracklist.setRandom', [true])}> if( this.props.random ){ button = this.props.mopidyActions.instruct('tracklist.setRandom', [false])}> } return button; } renderRepeatButton(){ var button = this.props.mopidyActions.instruct('tracklist.setRepeat', [true])}> if( this.props.repeat ){ button = this.props.mopidyActions.instruct('tracklist.setRepeat', [false])}> } return button; } renderArtwork(){ if( !this.props.current_track || !this.props.current_track.album || !this.props.current_track.album.images ){ return ( ) } var link = null if( this.props.current_track.album.uri ) link = '/album/'+this.props.current_track.album.uri return ( ) } render(){ return (
{ this.renderArtwork() }
{ this.props.current_track ? this.props.current_track.name : null }
{ this.props.current_track ? : null }
this.props.mopidyActions.previous()}>   { this.renderPlayButton() } this.props.mopidyActions.stop()}>   this.props.mopidyActions.next()}>  
{ this.renderConsumeButton() } { this.renderRandomButton() } { this.renderRepeatButton() }
{ this.props.time_position ? : '-' } { this.props.current_track ? : '-' }
); } } /** * 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, time_position: state.mopidy.time_position, consume: state.mopidy.consume, repeat: state.mopidy.repeat, random: state.mopidy.random } } const mapDispatchToProps = (dispatch) => { return { mopidyActions: bindActionCreators(mopidyActions, dispatch) } } export default connect(mapStateToProps, mapDispatchToProps)(FullPlayer)