Browse Source

Send current song to MPRIS when auto increment

master
jeffvli 3 years ago
committed by Jeff
parent
commit
cb4c968949
  1. 24
      src/components/player/Player.tsx
  2. 2
      src/redux/playQueueSlice.ts

24
src/components/player/Player.tsx

@ -22,6 +22,7 @@ import {
setCurrentIndex,
setFadeData,
setPlayerSrc,
getNextPlayerIndex,
} from '../../redux/playQueueSlice';
import { setCurrentSeek } from '../../redux/playerSlice';
import cacheSong from '../shared/cacheSong';
@ -398,6 +399,17 @@ const Player = ({ currentEntryList, children }: any, ref: any) => {
dispatch(setIsFading(false));
}
ipcRenderer.send(
'current-song',
playQueue[currentEntryList][
getNextPlayerIndex(
playQueue[currentEntryList].length,
playQueue.repeat,
playQueue.player1.index
)
]
);
dispatch(setAutoIncremented(false));
}
}
@ -431,6 +443,18 @@ const Player = ({ currentEntryList, children }: any, ref: any) => {
dispatch(setPlayerVolume({ player: 2, volume: 0 }));
dispatch(setIsFading(false));
}
ipcRenderer.send(
'current-song',
playQueue[currentEntryList][
getNextPlayerIndex(
playQueue[currentEntryList].length,
playQueue.repeat,
playQueue.player2.index
)
]
);
dispatch(setAutoIncremented(false));
}
}

2
src/redux/playQueueSlice.ts

@ -168,7 +168,7 @@ const removeItem = (array: any, index: any) => {
const entrySelect = (state: PlayQueue) =>
state.sortedEntry.length > 0 ? 'sortedEntry' : state.shuffle ? 'shuffledEntry' : 'entry';
const getNextPlayerIndex = (length: number, repeat: string, currentIndex: number) => {
export const getNextPlayerIndex = (length: number, repeat: string, currentIndex: number) => {
if (length >= 2 && repeat !== 'one') {
if (currentIndex + 1 === length) {
return 0;

Loading…
Cancel
Save