import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import { bindActionCreators } from 'redux'
import ProgressSlider from './Fields/ProgressSlider'
import VolumeControl from './Fields/VolumeControl'
import SnapcastVolumeControl from './Fields/SnapcastVolumeControl'
import Dater from './Dater'
import ArtistSentence from './ArtistSentence'
import Thumbnail from './Thumbnail'
import Icon from './Icon'
import * as helpers from '../helpers'
import * as uiActions from '../services/ui/actions'
import * as coreActions from '../services/core/actions'
import * as mopidyActions from '../services/mopidy/actions'
class PlaybackControls extends React.Component{
constructor(props){
super(props)
this.stream = null;
this.state = {
expanded: false
}
}
componentDidMount(){
if (this.props.http_streaming_enabled){
this.playStream();
}
}
playStream(props = this.props){
if (!this.stream){
this.stream = new Audio();
} else {
this.stream.src = null;
}
if (!props.current_track || !props.http_streaming_enabled || !props.http_streaming_url){
return false;
}
var url = props.http_streaming_url+"?cache_buster="+props.current_track.uri;
console.log("Playing stream: "+url);
this.stream.src = url;
this.stream.play();
}
componentWillReceiveProps(nextProps){
if (!this.props.current_track && nextProps.current_track ||
this.props.current_track && nextProps.current_track && this.props.current_track.uri !== nextProps.current_track.uri){
this.playStream(nextProps);
}
}
renderPlayButton(){
var button = this.props.mopidyActions.play()}>