2018-07-13 16:48:41 +12:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react';
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import { Link } from 'react-router';
|
|
|
|
|
import { createStore, bindActionCreators } from 'redux';
|
|
|
|
|
|
|
|
|
|
import Modal from './Modal';
|
|
|
|
|
import Thumbnail from '../../components/Thumbnail';
|
|
|
|
|
import ArtistSentence from '../../components/ArtistSentence';
|
2018-08-21 21:49:43 +12:00
|
|
|
import Dater from '../../components/Dater';
|
|
|
|
|
import Icon from '../../components/Icon';
|
|
|
|
|
import ProgressSlider from '../../components/Fields/ProgressSlider';
|
2018-07-13 16:48:41 +12:00
|
|
|
|
|
|
|
|
import * as helpers from '../../helpers';
|
|
|
|
|
import * as uiActions from '../../services/ui/actions';
|
2018-08-21 21:49:43 +12:00
|
|
|
import * as mopidyActions from '../../services/mopidy/actions';
|
2018-07-13 16:48:41 +12:00
|
|
|
|
|
|
|
|
class KioskMode extends React.Component{
|
|
|
|
|
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount(){
|
|
|
|
|
this.setWindowTitle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps){
|
|
|
|
|
if (!this.props.current_track && nextProps.current_track){
|
|
|
|
|
this.setWindowTitle(nextProps.current_track);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setWindowTitle(current_track = this.props.current_track){
|
|
|
|
|
if (current_track){
|
|
|
|
|
var artists = "";
|
|
|
|
|
for (var i = 0; i < current_track.artists.length; i++){
|
|
|
|
|
if (artists != ""){
|
|
|
|
|
artists += ", ";
|
|
|
|
|
}
|
|
|
|
|
artists += current_track.artists[i].name;
|
|
|
|
|
}
|
|
|
|
|
this.props.uiActions.setWindowTitle(current_track.name+" by "+artists+" (now playing)");
|
|
|
|
|
} else{
|
|
|
|
|
this.props.uiActions.setWindowTitle("Now playing");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 21:49:43 +12:00
|
|
|
togglePlay(e){
|
|
|
|
|
if (this.props.play_state == 'playing'){
|
|
|
|
|
this.props.mopidyActions.pause();
|
|
|
|
|
} else {
|
|
|
|
|
this.props.mopidyActions.play();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-13 16:48:41 +12:00
|
|
|
render(){
|
|
|
|
|
if (this.props.current_track && this.props.current_track.images){
|
|
|
|
|
var images = this.props.current_track.images
|
|
|
|
|
} else {
|
|
|
|
|
var images = []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Modal className="modal--kiosk-mode">
|
|
|
|
|
|
|
|
|
|
<Thumbnail className="background" images={images} />
|
2018-08-21 21:49:43 +12:00
|
|
|
|
|
|
|
|
<div className="artwork" onClick={e => this.togglePlay(e)}>
|
|
|
|
|
<Thumbnail images={images} />
|
|
|
|
|
{this.props.play_state == 'playing' ? <Icon name="pause_circle_filled" /> : <Icon name="play_circle_filled" />}
|
|
|
|
|
</div>
|
2018-07-13 16:48:41 +12:00
|
|
|
|
|
|
|
|
<div className="player">
|
|
|
|
|
<div className="current-track">
|
|
|
|
|
<div className="title">{ this.props.current_track ? this.props.current_track.name : <span>-</span> }</div>
|
|
|
|
|
{ this.props.current_track ? <ArtistSentence nolinks artists={ this.props.current_track.artists } /> : <ArtistSentence /> }
|
|
|
|
|
</div>
|
2018-08-21 21:49:43 +12:00
|
|
|
|
|
|
|
|
<div className="progress-wrapper">
|
|
|
|
|
<ProgressSlider />
|
|
|
|
|
</div>
|
2018-07-13 16:48:41 +12:00
|
|
|
</div>
|
|
|
|
|
</Modal>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => {
|
|
|
|
|
return {
|
2018-08-21 21:49:43 +12:00
|
|
|
play_state: state.mopidy.play_state,
|
2018-07-13 16:48:41 +12:00
|
|
|
current_track: (state.core.current_track && state.core.tracks[state.core.current_track.uri] !== undefined ? state.core.tracks[state.core.current_track.uri] : null),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
2018-08-21 21:49:43 +12:00
|
|
|
uiActions: bindActionCreators(uiActions, dispatch),
|
|
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch)
|
2018-07-13 16:48:41 +12:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(KioskMode)
|