This commit is contained in:
Jordan Eldredge 2019-01-23 10:06:30 -08:00
parent 2cd4f7e100
commit 59666b8699
4 changed files with 30 additions and 4 deletions

View file

@ -8,6 +8,17 @@ const USER_PRESET_TRANSITION_SECONDS = 5.7;
const PRESET_TRANSITION_SECONDS = 2.7;
const MILLISECONDS_BETWEEN_PRESET_TRANSITIONS = 15000;
function transitionTimeFromTransitionType(transitionType) {
switch (transitionType) {
case "DEFAULT":
return PRESET_TRANSITION_SECONDS;
case "IMMEDIATE":
return 0;
case "USER_PRESET":
return USER_PRESET_TRANSITION_SECONDS;
}
}
class Milkdrop extends React.Component {
constructor(props) {
super(props);
@ -195,7 +206,7 @@ class Milkdrop extends React.Component {
this.selectPreset(await this.props.presets.previous(), blendTime);
}
selectPreset(preset, blendTime = 0) {
selectPreset(preset, blendTime) {
if (preset != null) {
this.visualizer.loadPreset(preset, blendTime);
this._restartCycling();
@ -265,7 +276,8 @@ class Milkdrop extends React.Component {
const mapStateToProps = state => ({
trackTitle: Selectors.getCurrentTrackDisplayName(state),
presets: Selectors.getPresets(state),
butterchurn: Selectors.getButterchurn(state)
butterchurn: Selectors.getButterchurn(state),
transitionType: Selectors.getPresetTransitionType(state)
});
export default connect(mapStateToProps)(Milkdrop);

View file

@ -4,17 +4,20 @@ import {
INITIALIZE_PRESETS,
GOT_BUTTERCHURN
} from "../actionTypes";
import { TransitionType } from "../types";
export interface MilkdropState {
desktop: boolean;
presets: any;
butterchurn: any;
transitionType: TransitionType;
}
const defaultMilkdropState = {
desktop: false,
presets: null,
butterchurn: null
butterchurn: null,
transitionType: TransitionType.DEFAULT
};
export const milkdrop = (

View file

@ -6,7 +6,8 @@ import {
WindowInfo,
LoadedURLTrack,
WindowPositions,
PlaylistStyle
PlaylistStyle,
TransitionType
} from "./types";
import { createSelector } from "reselect";
import * as Utils from "./utils";
@ -620,3 +621,7 @@ export function getPresets(state: AppState): any {
export function getButterchurn(state: AppState): any {
return state.milkdrop.butterchurn;
}
export function getPresetTransitionType(state: AppState): TransitionType {
return state.milkdrop.transitionType;
}

View file

@ -146,6 +146,12 @@ export interface EqfPreset {
preamp: number;
}
export enum TransitionType {
IMMEDIATE,
DEFAULT,
USER_PRESET
}
export type Action =
| {
type: "@@init";