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 * as mopidyActions from '../services/mopidy/actions'
class Player extends React.Component{
constructor(props) {
super(props);
}
renderPlayButton(){
var button = this.props.mopidyActions.play()}>
if( this.props.mopidy.state == 'playing' ){
button = this.props.mopidyActions.pause()}>
}
return button;
}
renderConsumeButton(){
var button = this.props.mopidyActions.instruct('tracklist.setConsume', [true])}>
if( this.props.mopidy.consume ){
button = this.props.mopidyActions.instruct('tracklist.setConsume', [false])}>
}
return button;
}
renderRandomButton(){
var button = this.props.mopidyActions.instruct('tracklist.setRandom', [true])}>
if( this.props.mopidy.random ){
button = this.props.mopidyActions.instruct('tracklist.setRandom', [false])}>
}
return button;
}
renderRepeatButton(){
var button = this.props.mopidyActions.instruct('tracklist.setRepeat', [true])}>
if( this.props.mopidy.repeat ){
button = this.props.mopidyActions.instruct('tracklist.setRepeat', [false])}>
}
return button;
}
renderMiniPlayer(){
var mopidy_track = false;
if( typeof(this.props.mopidy.current_tltrack) !== 'undefined' && typeof(this.props.mopidy.current_tltrack.track) !== 'undefined' ) mopidy_track = this.props.mopidy.current_tltrack;
return (
{ mopidy_track ? mopidy_track.track.name : null }
{ mopidy_track ?
: null }
);
}
renderFullPlayer(){
var mopidy_track = false;
var images = [];
if( typeof(this.props.mopidy.current_tltrack) !== 'undefined' && typeof(this.props.mopidy.current_tltrack.track) !== 'undefined' ){
mopidy_track = this.props.mopidy.current_tltrack;
}
return (
{ this.props.spotify.track && !this.props.mini ?
:
}
{ this.renderConsumeButton() }
{ this.renderRandomButton() }
{ this.renderRepeatButton() }
{ mopidy_track ? mopidy_track.track.name : null }
{ mopidy_track ?
: null }
);
}
render(){
if( this.props.mini ){
return this.renderMiniPlayer()
}else{
return this.renderFullPlayer()
}
}
}
/**
* Export our component
*
* We also integrate our global store, using connect()
**/
const mapStateToProps = (state, ownProps) => {
return state;
}
const mapDispatchToProps = (dispatch) => {
return {
mopidyActions: bindActionCreators(mopidyActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Player)