Make default volume match actual Winamp's volume upon install.

This commit is contained in:
Jordan Eldredge 2017-12-14 17:21:35 -08:00
parent 7b7d4e2a88
commit 253f29218a
2 changed files with 12 additions and 1 deletions

View file

@ -21,6 +21,13 @@ import { next as nextTrack } from "./actionCreators";
import { getCurrentTrackId } from "./selectors";
export default media => store => {
const { media: { volume, balance } } = store.getState();
// Ensure the default state is the canonical value.
media.setVolume(volume);
media.setBalance(balance);
// TODO: Ensure other values like bands and preamp are in sync
media.addEventListener("timeupdate", () => {
store.dispatch({
type: UPDATE_TIME_ELAPSED,
@ -57,6 +64,7 @@ export default media => store => {
});
return next => action => {
// TODO: Consider doing this after the action, and using the state as the source of truth.
switch (action.type) {
case PLAY:
media.play();

View file

@ -204,7 +204,10 @@ const media = (state, action) => {
length: null, // Consider renaming to "duration"
kbps: null,
khz: null,
volume: 50,
// The winamp ini file declares the default volume as "200".
// The UI seems to show a default volume near 78, which would
// math with the default value being 200 out of 255.
volume: Math.round(200 / 255 * 100),
balance: 0,
channels: null,
shuffle: false,