Allow jumping to lyrics (#656)
This commit is contained in:
parent
0768ce80a7
commit
ea865f44b1
2 changed files with 8 additions and 1 deletions
|
@ -26,6 +26,10 @@ const StyledText = styled(TextTitle)<TitleProps & { $alignment: string; $fontSiz
|
||||||
&.unsynchronized {
|
&.unsynchronized {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.synchronized {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const LyricLine = ({ text, alignment, fontSize, ...props }: LyricLineProps) => {
|
export const LyricLine = ({ text, alignment, fontSize, ...props }: LyricLineProps) => {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import isElectron from 'is-electron';
|
||||||
import { PlayersRef } from '/@/renderer/features/player/ref/players-ref';
|
import { PlayersRef } from '/@/renderer/features/player/ref/players-ref';
|
||||||
import { FullLyricsMetadata, SynchronizedLyricsArray } from '/@/renderer/api/types';
|
import { FullLyricsMetadata, SynchronizedLyricsArray } from '/@/renderer/api/types';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { useCenterControls } from '/@/renderer/features/player/hooks/use-center-controls';
|
||||||
|
|
||||||
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@ export const SynchronizedLyrics = ({
|
||||||
const playbackType = usePlaybackType();
|
const playbackType = usePlaybackType();
|
||||||
const now = useCurrentTime();
|
const now = useCurrentTime();
|
||||||
const settings = useLyricsSettings();
|
const settings = useLyricsSettings();
|
||||||
|
const centerControls = useCenterControls({ playersRef });
|
||||||
|
|
||||||
const seeked = useSeeked();
|
const seeked = useSeeked();
|
||||||
|
|
||||||
|
@ -331,7 +333,7 @@ export const SynchronizedLyrics = ({
|
||||||
text={`"${name} by ${artist}"`}
|
text={`"${name} by ${artist}"`}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{lyrics.map(([, text], idx) => (
|
{lyrics.map(([time, text], idx) => (
|
||||||
<LyricLine
|
<LyricLine
|
||||||
key={idx}
|
key={idx}
|
||||||
alignment={settings.alignment}
|
alignment={settings.alignment}
|
||||||
|
@ -339,6 +341,7 @@ export const SynchronizedLyrics = ({
|
||||||
fontSize={settings.fontSize}
|
fontSize={settings.fontSize}
|
||||||
id={`lyric-${idx}`}
|
id={`lyric-${idx}`}
|
||||||
text={text}
|
text={text}
|
||||||
|
onClick={() => centerControls.handleSeekSlider(time / 1000)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</SynchronizedLyricsContainer>
|
</SynchronizedLyricsContainer>
|
||||||
|
|
Reference in a new issue