Revert "Show indicator on current playing song. Fixes #128"

This implementation causes performance issues
This commit is contained in:
Deluan
2020-06-13 16:39:57 -04:00
parent 86bc8d97a0
commit 72b2e756f7
9 changed files with 31 additions and 109 deletions
+8 -7
View File
@@ -5,7 +5,7 @@ import { useAuthState, useDataProvider, useTranslate } from 'react-admin'
import ReactJkMusicPlayer from 'react-jinke-music-player'
import 'react-jinke-music-player/assets/index.css'
import subsonic from '../subsonic'
import { scrobble, syncQueue, progress } from './queue'
import { scrobble, syncQueue } from './queue'
import themes from '../themes'
import { makeStyles } from '@material-ui/core/styles'
@@ -100,12 +100,8 @@ const Player = () => {
}
const OnAudioProgress = (info) => {
if (info.ended) {
document.title = 'Navidrome'
}
dispatch(progress(info))
const pos = (info.currentTime / info.duration) * 100
if (isNaN(info.duration) || pos < 90) {
const progress = (info.currentTime / info.duration) * 100
if (isNaN(info.duration) || progress < 90) {
return
}
const item = queue.queue.find((item) => item.trackId === info.trackId)
@@ -124,6 +120,10 @@ const Player = () => {
}
}
const onAudioEnded = () => {
document.title = 'Navidrome'
}
if (authenticated && options.audioLists.length > 0) {
return (
<ReactJkMusicPlayer
@@ -131,6 +131,7 @@ const Player = () => {
onAudioListsChange={OnAudioListsChange}
onAudioProgress={OnAudioProgress}
onAudioPlay={OnAudioPlay}
onAudioEnded={onAudioEnded}
/>
)
}
+2 -23
View File
@@ -6,7 +6,6 @@ const PLAYER_SET_TRACK = 'PLAYER_SET_TRACK'
const PLAYER_SYNC_QUEUE = 'PLAYER_SYNC_QUEUE'
const PLAYER_SCROBBLE = 'PLAYER_SCROBBLE'
const PLAYER_PLAY_TRACKS = 'PLAYER_PLAY_TRACKS'
const PLAYER_PROGRESS = 'PLAYER_PROGRESS'
const mapToAudioLists = (item) => {
// If item comes from a playlist, id is mediaFileId
@@ -89,30 +88,13 @@ const scrobble = (id, submit) => ({
submit,
})
const progress = (audioInfo) => ({
type: PLAYER_PROGRESS,
data: audioInfo,
})
const playQueueReducer = (
previousState = { queue: [], clear: true, playing: false, current: {} },
previousState = { queue: [], clear: true, playing: false },
payload
) => {
let queue, current
let queue
const { type, data } = payload
switch (type) {
case PLAYER_PROGRESS:
queue = previousState.queue
current = data.ended
? {}
: {
trackId: data.trackId,
paused: data.paused,
}
return {
...previousState,
current,
}
case PLAYER_ADD_TRACKS:
queue = previousState.queue
Object.keys(data).forEach((id) => {
@@ -127,12 +109,10 @@ const playQueueReducer = (
playing: true,
}
case PLAYER_SYNC_QUEUE:
current = data.length > 0 ? previousState.current : {}
return {
...previousState,
queue: data,
clear: false,
current,
}
case PLAYER_SCROBBLE:
const newQueue = previousState.queue.map((item) => {
@@ -176,7 +156,6 @@ export {
playTracks,
syncQueue,
scrobble,
progress,
shuffleTracks,
playQueueReducer,
}