forked from nukeop/nuclear
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
159 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { formatDuration } from '@nuclear/ui'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { playerSelectors } from '../../selectors/player'; | ||
import { queue as queueSelector } from '../../selectors/queue'; | ||
|
||
export const useSeekbarProps = () => { | ||
const queue = useSelector(queueSelector); | ||
const seek = useSelector(playerSelectors.seek); | ||
const currentTrackStream = _.head( | ||
_.get( | ||
queue.queueItems[queue.currentSong], | ||
'streams' | ||
) | ||
); | ||
|
||
const currentTrackDuration = _.get( | ||
currentTrackStream, | ||
'duration' | ||
); | ||
|
||
const timeToEnd = currentTrackDuration - seek; | ||
|
||
return { | ||
queue, | ||
timePlayed: formatDuration(seek), | ||
timeToEnd: formatDuration(timeToEnd) | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { useSelector /* useDispatch*/ } from 'react-redux'; | ||
import Sound from 'react-hifi'; | ||
import { PlayerBar } from '@nuclear/ui'; | ||
|
||
// import * as PlayerActions from '../../actions/player'; | ||
import { playerSelectors } from '../../selectors/player'; | ||
import { useSeekbarProps } from './hooks'; | ||
|
||
const PlayerBarContainer = () => { | ||
// const dispatch = useDispatch(); | ||
const playbackProgress = useSelector(playerSelectors.playbackProgress); | ||
const playbackStatus = useSelector(playerSelectors.playbackStatus); | ||
const playbackStreamLoading = useSelector(playerSelectors.playbackStreamLoading); | ||
|
||
const seekbarProps = useSeekbarProps(); | ||
|
||
return ( | ||
<PlayerBar | ||
{...seekbarProps} | ||
renderTrackDuration | ||
fill={playbackProgress} | ||
track='Test song' | ||
artist='Test artist' | ||
volume={60} | ||
seek={null} | ||
playOptions={[ | ||
{ icon: 'repeat', enabled: false }, | ||
{ icon: 'magic' }, | ||
{ icon: 'random', enabled: false } | ||
]} | ||
isPlaying={playbackStatus === Sound.status.PLAYING} | ||
isLoading={playbackStreamLoading} | ||
/> | ||
); | ||
}; | ||
|
||
export default PlayerBarContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createStateSelectors } from './helpers'; | ||
|
||
export const playerSelectors = createStateSelectors( | ||
'player', | ||
[ | ||
'playbackProgress', | ||
'playbackStatus', | ||
'playbackStreamLoading', | ||
'seek' | ||
] | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const queue = s => s.queue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
@import '../../common.scss'; | ||
|
||
.seekbar_container { | ||
height: 1em; | ||
.seekbar { | ||
position: relative; | ||
height: 1.25em; | ||
cursor: pointer; | ||
background-color: transparent; | ||
background-color: $background2; | ||
flex: 0 0 auto; | ||
} | ||
|
||
.seekbar_fill { | ||
height: 100%; | ||
background-color: $pink; | ||
&:hover { | ||
height: 1.5em; | ||
} | ||
|
||
.seekbar_progress { | ||
height: 100%; | ||
background-color: $pink; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react", | ||
"moduleResolution": "node", | ||
"target": "ESNext", | ||
"module":"ESNext", | ||
|