Start player in pause mode if windows is reloaded/refreshed. Fixes #457

This commit is contained in:
Deluan
2020-09-24 09:37:28 -04:00
parent 2230a9052f
commit a1c670b40d
2 changed files with 22 additions and 4 deletions
+2 -1
View File
@@ -44,7 +44,7 @@ const Player = () => {
autoPlay: true, autoPlay: true,
preload: true, preload: true,
autoPlayInitLoadPlayList: true, autoPlayInitLoadPlayList: true,
// loadAudioErrorPlayNext: false, loadAudioErrorPlayNext: false,
clearPriorAudioLists: false, clearPriorAudioLists: false,
showDestroy: false, showDestroy: false,
showDownload: false, showDownload: false,
@@ -94,6 +94,7 @@ const Player = () => {
return { return {
...defaultOptions, ...defaultOptions,
clearPriorAudioLists: queue.clear, clearPriorAudioLists: queue.clear,
playIndex: queue.playIndex,
audioLists: queue.queue.map((item) => item), audioLists: queue.queue.map((item) => item),
defaultVolume: queue.volume, defaultVolume: queue.volume,
} }
+20 -3
View File
@@ -117,7 +117,13 @@ const setVolume = (volume) => ({
data: { volume }, data: { volume },
}) })
const initialState = { queue: [], clear: true, current: {}, volume: 1 } const initialState = {
queue: [],
clear: true,
current: {},
volume: 1,
playIndex: 0,
}
const playQueueReducer = (previousState = initialState, payload) => { const playQueueReducer = (previousState = initialState, payload) => {
let queue, current let queue, current
@@ -129,6 +135,7 @@ const playQueueReducer = (previousState = initialState, payload) => {
case PLAYER_SET_VOLUME: case PLAYER_SET_VOLUME:
return { return {
...previousState, ...previousState,
playIndex: undefined,
volume: data.volume, volume: data.volume,
} }
case PLAYER_CURRENT: case PLAYER_CURRENT:
@@ -143,6 +150,7 @@ const playQueueReducer = (previousState = initialState, payload) => {
return { return {
...previousState, ...previousState,
current, current,
playIndex: undefined,
volume: data.volume, volume: data.volume,
} }
case PLAYER_ADD_TRACKS: case PLAYER_ADD_TRACKS:
@@ -150,7 +158,7 @@ const playQueueReducer = (previousState = initialState, payload) => {
Object.keys(data).forEach((id) => { Object.keys(data).forEach((id) => {
queue.push(mapToAudioLists(data[id])) queue.push(mapToAudioLists(data[id]))
}) })
return { ...previousState, queue, clear: false } return { ...previousState, queue, clear: false, playIndex: undefined }
case PLAYER_PLAY_NEXT: case PLAYER_PLAY_NEXT:
current = get(previousState.current, 'uuid', '') current = get(previousState.current, 'uuid', '')
newQueue = [] newQueue = []
@@ -169,12 +177,18 @@ const playQueueReducer = (previousState = initialState, payload) => {
newQueue.push(mapToAudioLists(data[id])) newQueue.push(mapToAudioLists(data[id]))
}) })
} }
return { ...previousState, queue: newQueue, clear: true } return {
...previousState,
queue: newQueue,
clear: true,
playIndex: undefined,
}
case PLAYER_SET_TRACK: case PLAYER_SET_TRACK:
return { return {
...previousState, ...previousState,
queue: [mapToAudioLists(data)], queue: [mapToAudioLists(data)],
clear: true, clear: true,
playIndex: 0,
} }
case PLAYER_SYNC_QUEUE: case PLAYER_SYNC_QUEUE:
current = data.length > 0 ? previousState.current : {} current = data.length > 0 ? previousState.current : {}
@@ -182,6 +196,7 @@ const playQueueReducer = (previousState = initialState, payload) => {
...previousState, ...previousState,
queue: data, queue: data,
clear: false, clear: false,
playIndex: undefined,
current, current,
} }
case PLAYER_SCROBBLE: case PLAYER_SCROBBLE:
@@ -195,6 +210,7 @@ const playQueueReducer = (previousState = initialState, payload) => {
return { return {
...previousState, ...previousState,
queue: newQueue, queue: newQueue,
playIndex: undefined,
clear: false, clear: false,
} }
case PLAYER_PLAY_TRACKS: case PLAYER_PLAY_TRACKS:
@@ -211,6 +227,7 @@ const playQueueReducer = (previousState = initialState, payload) => {
return { return {
...previousState, ...previousState,
queue, queue,
playIndex: 0,
clear: true, clear: true,
} }
default: default: