Full refactor of current_track; Removing of crossOrigin in parallax
This commit is contained in:
@ -27,12 +27,12 @@ export default class Dater extends React.Component{
|
||||
// get left-over number of seconds
|
||||
seconds = total_seconds - (total_minutes * 60 )
|
||||
if (seconds <= 9) seconds = '0'+ seconds
|
||||
if (seconds == 0) seconds = '00'
|
||||
if (seconds == 0) seconds = '0'
|
||||
|
||||
// get left-over number of minutes
|
||||
minutes = total_minutes - (total_hours * 60 )
|
||||
if (minutes <= 9 && total_hours) minutes = '0'+ minutes
|
||||
if (minutes == 0) minutes = '00'
|
||||
if (minutes == 0) minutes = '0'
|
||||
|
||||
if (total_hours) string += total_hours+':'
|
||||
if (minutes) string += minutes+':'
|
||||
|
||||
@ -145,7 +145,7 @@ class Modal extends React.Component{
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
current_track: (state.core.current_track !== undefined && state.core.tracks !== undefined && state.core.tracks[state.core.current_track.uri] !== undefined ? state.core.tracks[state.core.current_track.uri] : null),
|
||||
current_track: (state.core.current_track !== undefined && state.core.tracks !== undefined && state.core.tracks[state.core.current_track] !== undefined ? state.core.tracks[state.core.current_track] : null),
|
||||
uri_schemes: (state.mopidy.uri_schemes ? state.mopidy.uri_schemes : []),
|
||||
search_uri_schemes: (state.ui.search_uri_schemes ? state.ui.search_uri_schemes : []),
|
||||
volume: state.mopidy.volume,
|
||||
|
||||
@ -61,16 +61,16 @@ export default class Parallax extends React.Component{
|
||||
|
||||
componentWillReceiveProps(nextProps){
|
||||
if ((!this.state.url || nextProps.image != this.state.url ) && !this._loading && nextProps.image){
|
||||
this._loading = true
|
||||
this.setState({ url: nextProps.image, image: false, loading: true })
|
||||
this.loadImage(nextProps.image )
|
||||
this._loading = true;
|
||||
this.setState({ url: nextProps.image, image: false, loading: true });
|
||||
this.loadImage(nextProps.image)
|
||||
.then(
|
||||
response => {
|
||||
if (this._mounted){
|
||||
this._loading = false
|
||||
this._loaded = true
|
||||
this.setState({ url: nextProps.image, image: response, loading: false })
|
||||
this.updateCanvas(response)
|
||||
this._loading = false;
|
||||
this._loaded = true;
|
||||
this.setState({ url: nextProps.image, image: response, loading: false });
|
||||
this.updateCanvas(response);
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -96,9 +96,13 @@ export default class Parallax extends React.Component{
|
||||
loadImage(url){
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
var imageObject = new Image()
|
||||
imageObject.src = url
|
||||
imageObject.crossOrigin = 'anonymous'
|
||||
var imageObject = new Image();
|
||||
imageObject.src = url;
|
||||
|
||||
// This seems to prevent Dirble images from loading.
|
||||
// Other domains don't seem to mind any more, so perhaps we can remove for good.
|
||||
// TODO: Re-test the nature of crossorigin images
|
||||
// imageObject.crossOrigin = 'anonymous';
|
||||
|
||||
imageObject.onload = function(){
|
||||
var image = {
|
||||
@ -108,7 +112,7 @@ export default class Parallax extends React.Component{
|
||||
original_height: imageObject.naturalHeight,
|
||||
object: imageObject
|
||||
}
|
||||
resolve(image )
|
||||
resolve(image);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -20,18 +20,20 @@ class ProgressSlider extends React.Component{
|
||||
var percent = (sliderX / sliderWidth ).toFixed(2);
|
||||
|
||||
if (this.props.connected && this.props.current_track){
|
||||
var destination_time = this.props.current_track.duration * percent
|
||||
this.props.mopidyActions.seek(destination_time )
|
||||
this.setState({ animating: false })
|
||||
var destination_time = this.props.current_track.duration * percent;
|
||||
this.props.mopidyActions.seek(destination_time);
|
||||
this.setState({ animating: false });
|
||||
}
|
||||
}
|
||||
|
||||
render(){
|
||||
var percent = 0
|
||||
var percent = 0;
|
||||
if (this.props.connected && this.props.current_track){
|
||||
percent = this.props.time_position / this.props.current_track.duration
|
||||
percent = this.props.time_position / this.props.current_track.duration;
|
||||
percent = percent * 100;
|
||||
if (percent > 100 ) percent = 100
|
||||
if (percent > 1000){
|
||||
percent = 100;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@ -52,7 +54,7 @@ class ProgressSlider extends React.Component{
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
current_track: (state.core.current_track !== undefined && state.core.tracks !== undefined && state.core.tracks[state.core.current_track.uri] !== undefined ? state.core.tracks[state.core.current_track.uri] : null),
|
||||
current_track: (state.core.current_track !== undefined && state.core.tracks !== undefined && state.core.tracks[state.core.current_track] !== undefined ? state.core.tracks[state.core.current_track] : null),
|
||||
connected: state.mopidy.connected,
|
||||
time_position: state.mopidy.time_position,
|
||||
play_state: state.mopidy.play_state
|
||||
|
||||
Reference in New Issue
Block a user