mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Add download button in the SharePlayer
This commit is contained in:
parent
a7d3e6e1f1
commit
b520d8827a
6 changed files with 33 additions and 9 deletions
|
@ -37,7 +37,7 @@ import config, { shareInfo } from './config'
|
|||
import { setDispatch, startEventStream, stopEventStream } from './eventStream'
|
||||
import { keyMap } from './hotkeys'
|
||||
import useChangeThemeColor from './useChangeThemeColor'
|
||||
import SharePlayer from './SharePlayer'
|
||||
import SharePlayer from './share/SharePlayer'
|
||||
|
||||
const history = createHashHistory()
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ReactJkMusicPlayer from 'navidrome-music-player'
|
||||
import { shareInfo } from './config'
|
||||
import { shareCoverUrl, shareStreamUrl } from './utils'
|
||||
import { shareInfo } from '../config'
|
||||
import { shareCoverUrl, shareDownloadUrl, shareStreamUrl } from '../utils'
|
||||
|
||||
import { makeStyles } from '@material-ui/core/styles'
|
||||
|
||||
|
@ -34,12 +34,17 @@ const SharePlayer = () => {
|
|||
duration: s.duration,
|
||||
}
|
||||
})
|
||||
const onBeforeAudioDownload = () => {
|
||||
return Promise.resolve({
|
||||
src: shareDownloadUrl(shareInfo?.id),
|
||||
})
|
||||
}
|
||||
const options = {
|
||||
audioLists: list,
|
||||
mode: 'full',
|
||||
toggleMode: false,
|
||||
mobileMediaQuery: '',
|
||||
showDownload: false,
|
||||
showDownload: shareInfo?.downloadable,
|
||||
showReload: false,
|
||||
showMediaSession: true,
|
||||
theme: 'auto',
|
||||
|
@ -49,7 +54,13 @@ const SharePlayer = () => {
|
|||
spaceBar: true,
|
||||
volumeFade: { fadeIn: 200, fadeOut: 200 },
|
||||
}
|
||||
return <ReactJkMusicPlayer {...options} className={classes.player} />
|
||||
return (
|
||||
<ReactJkMusicPlayer
|
||||
{...options}
|
||||
className={classes.player}
|
||||
onBeforeAudioDownload={onBeforeAudioDownload}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export default SharePlayer
|
|
@ -19,6 +19,10 @@ export const shareStreamUrl = (id) => {
|
|||
return baseUrl(config.publicBaseUrl + '/s/' + id)
|
||||
}
|
||||
|
||||
export const shareDownloadUrl = (id) => {
|
||||
return baseUrl(config.publicBaseUrl + '/d/' + id)
|
||||
}
|
||||
|
||||
export const shareCoverUrl = (id) => {
|
||||
return baseUrl(config.publicBaseUrl + '/img/' + id + '?size=300')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue