From d932bb38f6d42829cad9b194d5350d60b8bd93fa Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Thu, 11 Aug 2016 21:25:08 -0700 Subject: [PATCH] Consolidate setting media info --- js/reducers.js | 19 +++++++++---------- js/winamp.js | 15 ++++++++------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/js/reducers.js b/js/reducers.js index 0391d1f1..3b4fafa6 100644 --- a/js/reducers.js +++ b/js/reducers.js @@ -108,20 +108,19 @@ const media = (state, action) => { return {...state, timeMode: newMode}; case 'UPDATE_TIME_ELAPSED': return {...state, timeElapsed: action.elapsed}; - case 'SET_MEDIA_LENGTH': - return {...state, length: action.length}; - case 'SET_MEDIA_KBPS': - return {...state, kbps: action.kbps}; - case 'SET_MEDIA_KHZ': - return {...state, khz: action.khz}; + case 'SET_MEDIA': + return { + ...state, + length: action.length, + kbps: action.kbps, + khz: action.khz, + channels: action.channels, + name: action.name + }; case 'SET_VOLUME': return {...state, volume: action.volume}; case 'SET_BALANCE': return {...state, balance: action.balance}; - case 'SET_MEDIA_NAME': - return {...state, name: action.name}; - case 'SET_CHANNELS_COUNT': - return {...state, channels: action.channels}; case 'TOGGLE_REPEAT': return {...state, repeat: !state.repeat}; case 'TOGGLE_SHUFFLE': diff --git a/js/winamp.js b/js/winamp.js index 268a5fda..92f1ee68 100755 --- a/js/winamp.js +++ b/js/winamp.js @@ -83,13 +83,14 @@ module.exports = { /* Listeners */ _loadBuffer: function(buffer) { function setMetaData() { - const kbps = '128'; - const khz = Math.round(this.media.sampleRate() / 1000).toString(); - this.dispatch({type: 'SET_MEDIA_KBPS', kbps: kbps}); - this.dispatch({type: 'SET_MEDIA_KHZ', khz: khz}); - this.dispatch({type: 'SET_CHANNELS_COUNT', channels: this.media.channels()}); - this.dispatch({type: 'SET_MEDIA_NAME', name: this.fileName}); - this.dispatch({type: 'SET_MEDIA_LENGTH', length: this.media.duration()}); + this.dispatch({ + type: 'SET_MEDIA', + kbps: '128', + khz: Math.round(this.media.sampleRate() / 1000).toString(), + channels: this.media.channels(), + name: this.fileName, + length: this.media.duration() + }); } // Note, this will not happen right away