Browse Source

player fixes

master
jeffvli 3 years ago
parent
commit
bcf43754ee
  1. 33
      src/components/player/Player.tsx
  2. 8
      src/redux/playQueueSlice.ts

33
src/components/player/Player.tsx

@ -308,7 +308,7 @@ const Player = ({ currentEntryList, children }: any, ref: any) => {
the currentSongIndex such as when sorting the table, shuffling, or drag and dropping rows.
It can also prevent loading unneeded tracks when rapidly incrementing/decrementing the player. */
if (playQueue[currentEntryList] && !playQueue.isFading) {
if (playQueue[currentEntryList].length > 0 && !playQueue.isFading) {
const timer1 = setTimeout(() => {
dispatch(setPlayerSrc({ player: 1, src: getSrc1() }));
}, 100);
@ -323,10 +323,13 @@ const Player = ({ currentEntryList, children }: any, ref: any) => {
};
}
/* If fading, just instantly switch the track, otherwise the player breaks
if (playQueue[currentEntryList].length > 0) {
/* If fading, just instantly switch the track, otherwise the player breaks
from the timeout due to the listen handlers that run during the fade */
dispatch(setPlayerSrc({ player: 1, src: getSrc1() }));
dispatch(setPlayerSrc({ player: 2, src: getSrc2() }));
dispatch(setPlayerSrc({ player: 1, src: getSrc1() }));
dispatch(setPlayerSrc({ player: 2, src: getSrc2() }));
}
return undefined;
}, [cachePath, currentEntryList, dispatch, getSrc1, getSrc2, playQueue]);
@ -505,10 +508,13 @@ const Player = ({ currentEntryList, children }: any, ref: any) => {
playQueue.currentPlayer === 1
}
onError={(e: any) => {
console.log('player error', e);
player1Ref.current.audioEl.current.src =
'./components/player/dummy.mp3';
player1Ref.current.audioEl.current.src = getSrc1();
if (playQueue[currentEntryList].length > 0) {
console.log('player error', e);
player1Ref.current.audioEl.current.src =
'./components/player/dummy.mp3';
player1Ref.current.audioEl.current.src = getSrc1();
}
}}
crossOrigin="anonymous"
/>
@ -527,10 +533,13 @@ const Player = ({ currentEntryList, children }: any, ref: any) => {
playQueue.currentPlayer === 2
}
onError={(e: any) => {
console.log('player error', e);
player2Ref.current.audioEl.current.src =
'./components/player/dummy.mp3';
player2Ref.current.audioEl.current.src = getSrc2();
if (playQueue[currentEntryList].length > 0) {
console.log('player error', e);
player2Ref.current.audioEl.current.src =
'./components/player/dummy.mp3';
player2Ref.current.audioEl.current.src = getSrc2();
}
}}
crossOrigin="anonymous"
/>

8
src/redux/playQueueSlice.ts

@ -83,7 +83,7 @@ export interface PlayQueue {
const initialState: PlayQueue = {
player1: {
src: '',
src: './components/player/dummy.mp3',
index: 0,
volume: 0.5,
fadeData: {
@ -92,7 +92,7 @@ const initialState: PlayQueue = {
},
},
player2: {
src: '',
src: './components/player/dummy.mp3',
index: 1,
volume: 0,
fadeData: {
@ -129,6 +129,8 @@ const resetPlayerDefaults = (state: PlayQueue) => {
state.currentIndex = 0;
state.currentSongId = '';
state.currentPlayer = 1;
state.player1.src = './components/player/dummy.mp3';
state.player2.src = './components/player/dummy.mp3';
state.player1.index = 0;
state.player1.volume = state.volume;
state.player2.index = 0;
@ -657,7 +659,7 @@ const playQueueSlice = createSlice({
Player2 will continue playing even after decrementing. This reducer resets the Player2 index and
then sets it to its proper index. */
state.player2.src = '';
state.player2.src = './components/player/dummy.mp3';
state.player2.index = getNextPlayerIndex(
state.entry.length,

Loading…
Cancel
Save