Play/Pause current song with <Space> key
This commit is contained in:
Generated
+15
@@ -7383,6 +7383,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz",
|
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz",
|
||||||
"integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg=="
|
"integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg=="
|
||||||
},
|
},
|
||||||
|
"hotkeys-js": {
|
||||||
|
"version": "3.8.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/hotkeys-js/-/hotkeys-js-3.8.1.tgz",
|
||||||
|
"integrity": "sha512-YlhVQtyG9f1b7GhtzdhR0Pl+cImD1ZrKI6zYUa7QLd0zuThiL7RzZ+ANJyy7z+kmcCpNYBf5PjBa3CjiQ5PFpw=="
|
||||||
|
},
|
||||||
"hpack.js": {
|
"hpack.js": {
|
||||||
"version": "2.1.6",
|
"version": "2.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz",
|
||||||
@@ -13494,6 +13499,16 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react-ga/-/react-ga-3.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/react-ga/-/react-ga-3.1.2.tgz",
|
||||||
"integrity": "sha512-OJrMqaHEHbodm+XsnjA6ISBEHTwvpFrxco65mctzl/v3CASMSLSyUkFqz9yYrPDKGBUfNQzKCjuMJwctjlWBbw=="
|
"integrity": "sha512-OJrMqaHEHbodm+XsnjA6ISBEHTwvpFrxco65mctzl/v3CASMSLSyUkFqz9yYrPDKGBUfNQzKCjuMJwctjlWBbw=="
|
||||||
},
|
},
|
||||||
|
"react-hot-keys": {
|
||||||
|
"version": "2.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-hot-keys/-/react-hot-keys-2.6.0.tgz",
|
||||||
|
"integrity": "sha512-q7UKLGxZyWhIeyNp4TIp5ardcIF5lPeS8Lmh5gTKH+4IOQDrfMkyvAoz1XFYKR2UDc4GW9sEDrzVrqVZu/HrAw==",
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.8.4",
|
||||||
|
"hotkeys-js": "^3.8.1",
|
||||||
|
"prop-types": "^15.7.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"react-icons": {
|
"react-icons": {
|
||||||
"version": "3.11.0",
|
"version": "3.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-3.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-3.11.0.tgz",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"react-dom": "^16.13.1",
|
"react-dom": "^16.13.1",
|
||||||
"react-drag-listview": "^0.1.7",
|
"react-drag-listview": "^0.1.7",
|
||||||
"react-ga": "^3.1.2",
|
"react-ga": "^3.1.2",
|
||||||
|
"react-hot-keys": "^2.6.0",
|
||||||
"react-icons": "^3.11.0",
|
"react-icons": "^3.11.0",
|
||||||
"react-image-lightbox": "^5.1.1",
|
"react-image-lightbox": "^5.1.1",
|
||||||
"react-jinke-music-player": "^4.18.3",
|
"react-jinke-music-player": "^4.18.3",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
import themes from '../themes'
|
import themes from '../themes'
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
import config from '../config'
|
import config from '../config'
|
||||||
|
import Hotkeys from 'react-hot-keys'
|
||||||
|
|
||||||
const useStyle = makeStyles((theme) => ({
|
const useStyle = makeStyles((theme) => ({
|
||||||
audioTitle: {
|
audioTitle: {
|
||||||
@@ -24,6 +25,8 @@ const useStyle = makeStyles((theme) => ({
|
|||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
let audioInstance = null
|
||||||
|
|
||||||
const Player = () => {
|
const Player = () => {
|
||||||
const classes = useStyle()
|
const classes = useStyle()
|
||||||
const translate = useTranslate()
|
const translate = useTranslate()
|
||||||
@@ -178,8 +181,26 @@ const Player = () => {
|
|||||||
})
|
})
|
||||||
}, [dispatch])
|
}, [dispatch])
|
||||||
|
|
||||||
|
const onKeyUp = useCallback((keyName, e) => {
|
||||||
|
if (keyName === 'space') {
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
const onKeyDown = useCallback((keyName, e) => {
|
||||||
|
if (keyName === 'space') {
|
||||||
|
e.preventDefault()
|
||||||
|
audioInstance && audioInstance.togglePlay()
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
if (authenticated && options.audioLists.length > 0) {
|
if (authenticated && options.audioLists.length > 0) {
|
||||||
return (
|
return (
|
||||||
|
<Hotkeys
|
||||||
|
keyName="space"
|
||||||
|
onKeyDown={onKeyDown}
|
||||||
|
onKeyUp={onKeyUp}
|
||||||
|
allowRepeat={false}
|
||||||
|
>
|
||||||
<ReactJkMusicPlayer
|
<ReactJkMusicPlayer
|
||||||
{...options}
|
{...options}
|
||||||
quietUpdate
|
quietUpdate
|
||||||
@@ -190,7 +211,11 @@ const Player = () => {
|
|||||||
onAudioEnded={onAudioEnded}
|
onAudioEnded={onAudioEnded}
|
||||||
onAudioVolumeChange={onAudioVolumeChange}
|
onAudioVolumeChange={onAudioVolumeChange}
|
||||||
onBeforeDestroy={onBeforeDestroy}
|
onBeforeDestroy={onBeforeDestroy}
|
||||||
|
getAudioInstance={(instance) => {
|
||||||
|
audioInstance = instance
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
</Hotkeys>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
document.title = 'Navidrome'
|
document.title = 'Navidrome'
|
||||||
|
|||||||
Reference in New Issue
Block a user