mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 17:47:16 +00:00
parent
4cf1550dea
commit
9f5c20d413
5 changed files with 19 additions and 9 deletions
|
|
@ -56,7 +56,7 @@ const loadQueue = new LoadQueue({ threads: 4 });
|
|||
|
||||
export function addTracksFromReferences(
|
||||
fileReferences: FileList,
|
||||
loadStyle: LoadStyle | null,
|
||||
loadStyle: LoadStyle,
|
||||
atIndex: number | undefined
|
||||
): Dispatchable {
|
||||
const tracks: Track[] = Array.from(fileReferences).map(file => ({
|
||||
|
|
@ -70,7 +70,7 @@ const SKIN_FILENAME_MATCHER = new RegExp("(wsz|zip)$", "i");
|
|||
const EQF_FILENAME_MATCHER = new RegExp("eqf$", "i");
|
||||
export function loadFilesFromReferences(
|
||||
fileReferences: FileList,
|
||||
loadStyle: LoadStyle | null = LOAD_STYLE.PLAY,
|
||||
loadStyle: LoadStyle = LOAD_STYLE.PLAY,
|
||||
atIndex: number | undefined = undefined
|
||||
): Dispatchable {
|
||||
return dispatch => {
|
||||
|
|
@ -206,7 +206,7 @@ export function fetchMediaDuration(url: string, id: number): Dispatchable {
|
|||
|
||||
export function loadMediaFiles(
|
||||
tracks: Track[],
|
||||
loadStyle: LoadStyle | null = null,
|
||||
loadStyle: LoadStyle = LOAD_STYLE.NONE,
|
||||
atIndex = 0
|
||||
): Dispatchable {
|
||||
return dispatch => {
|
||||
|
|
@ -216,7 +216,7 @@ export function loadMediaFiles(
|
|||
dispatch(removeAllTracks());
|
||||
}
|
||||
tracks.forEach((track, i) => {
|
||||
const priority = i === 0 && loadStyle != null ? loadStyle : null;
|
||||
const priority = i === 0 ? loadStyle : LOAD_STYLE.NONE;
|
||||
dispatch(loadMediaFile(track, priority, atIndex + i));
|
||||
});
|
||||
};
|
||||
|
|
@ -224,7 +224,7 @@ export function loadMediaFiles(
|
|||
|
||||
export function loadMediaFile(
|
||||
track: Track,
|
||||
priority: LoadStyle | null = null,
|
||||
priority: LoadStyle = LOAD_STYLE.NONE,
|
||||
atIndex = 0
|
||||
): Dispatchable {
|
||||
return dispatch => {
|
||||
|
|
@ -253,6 +253,7 @@ export function loadMediaFile(
|
|||
case LOAD_STYLE.PLAY:
|
||||
dispatch({ type: PLAY_TRACK, id });
|
||||
break;
|
||||
case LOAD_STYLE.NONE:
|
||||
default:
|
||||
// If we're not going to load this right away,
|
||||
// we should set duration on our own
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ import {
|
|||
getSkinPlaylistStyle
|
||||
} from "../../selectors";
|
||||
|
||||
import { LOAD_STYLE } from "../../constants";
|
||||
|
||||
import { clamp } from "../../utils";
|
||||
import DropTarget from "../DropTarget";
|
||||
import Visualizer from "../Visualizer";
|
||||
|
|
@ -200,7 +202,13 @@ const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => {
|
|||
scrollUpFourTracks: () => dispatch(scrollUpFourTracks()),
|
||||
scrollDownFourTracks: () => dispatch(scrollDownFourTracks()),
|
||||
loadFilesFromReferences: (e, startIndex) =>
|
||||
dispatch(loadFilesFromReferences(e.dataTransfer.files, null, startIndex)),
|
||||
dispatch(
|
||||
loadFilesFromReferences(
|
||||
e.dataTransfer.files,
|
||||
LOAD_STYLE.NONE,
|
||||
startIndex
|
||||
)
|
||||
),
|
||||
scrollVolume: e => dispatch(scrollVolume(e))
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ export const WINDOWS = {
|
|||
|
||||
export const LOAD_STYLE: Record<LoadStyle, LoadStyle> = {
|
||||
BUFFER: "BUFFER",
|
||||
PLAY: "PLAY"
|
||||
PLAY: "PLAY",
|
||||
NONE: "NONE"
|
||||
};
|
||||
|
||||
// TODO: Make this an enum?
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ export type MediaTagRequestStatus =
|
|||
|
||||
export type MediaStatus = "PLAYING" | "STOPPED" | "PAUSED";
|
||||
|
||||
export type LoadStyle = "BUFFER" | "PLAY";
|
||||
export type LoadStyle = "BUFFER" | "PLAY" | "NONE";
|
||||
|
||||
export type TimeMode = "ELAPSED" | "REMAINING";
|
||||
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ class Winamp {
|
|||
appendTracks(tracks) {
|
||||
const nextIndex = Selectors.getTrackCount(this.store.getState());
|
||||
this.store.dispatch(
|
||||
Actions.loadMediaFiles(tracks, LOAD_STYLE.BUFFER, nextIndex)
|
||||
Actions.loadMediaFiles(tracks, LOAD_STYLE.NONE, nextIndex)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue