File tree 5 files changed +38
-1
lines changed
5 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 752
752
},
753
753
"tooltip" : " Choose the effect to apply to the current line"
754
754
},
755
+ "offset" : {
756
+ "label" : " Lyrics offset" ,
757
+ "tooltip" : " Set the offset for the lyrics (useful when using bluetooth speakers)" ,
758
+ "prompt" : {
759
+ "title" : " Lyrics offset" ,
760
+ "label" : " Set the lyrics offset in ms"
761
+ }
762
+ },
755
763
"precise-timing" : {
756
764
"label" : " Make the lyrics perfectly synced" ,
757
765
"tooltip" : " Calculate to the milisecond the display of the next line (can have a small impact on performance)"
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export default createPlugin({
16
16
config : {
17
17
enabled : false ,
18
18
preciseTiming : true ,
19
+ lyricsOffset : 0 ,
19
20
showLyricsEvenIfInexact : true ,
20
21
showTimeCodes : false ,
21
22
defaultTextString : '♪' ,
Original file line number Diff line number Diff line change
1
+ import prompt from 'custom-electron-prompt' ;
2
+
1
3
import { t } from '@/i18n' ;
4
+ import promptOptions from '@/providers/prompt-options' ;
2
5
3
6
import type { MenuItemConstructorOptions } from 'electron' ;
4
7
import type { MenuContext } from '@/types/contexts' ;
@@ -10,6 +13,30 @@ export const menu = async (
10
13
const config = await ctx . getConfig ( ) ;
11
14
12
15
return [
16
+ {
17
+ label : t ( 'plugins.synced-lyrics.menu.offset.label' ) ,
18
+ toolTip : t ( 'plugins.synced-lyrics.menu.offset.tooltip' ) ,
19
+ type : 'normal' ,
20
+ async click ( ) {
21
+ const config = await ctx . getConfig ( ) ;
22
+ const newOffset = await prompt (
23
+ {
24
+ title : t ( 'plugins.synced-lyrics.menu.offset.prompt.title' ) ,
25
+ label : t ( 'plugins.synced-lyrics.menu.offset.prompt.label' ) ,
26
+ value : config . lyricsOffset || 0 ,
27
+ type : 'counter' ,
28
+ counterOptions : { multiFire : true } ,
29
+ width : 380 ,
30
+ ...promptOptions ( ) ,
31
+ } ,
32
+ ctx . window ,
33
+ ) ;
34
+
35
+ ctx . setConfig ( {
36
+ lyricsOffset : newOffset ?? config . lyricsOffset ,
37
+ } ) ;
38
+ } ,
39
+ } ,
13
40
{
14
41
label : t ( 'plugins.synced-lyrics.menu.precise-timing.label' ) ,
15
42
toolTip : t ( 'plugins.synced-lyrics.menu.precise-timing.tooltip' ) ,
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ interface SyncedLineProps {
24
24
25
25
export const SyncedLine = ( props : SyncedLineProps ) => {
26
26
const status = createMemo ( ( ) => {
27
- const current = currentTime ( ) ;
27
+ const current = Math . max ( 0 , currentTime ( ) - ( config ( ) ?. lyricsOffset ?? 0 ) ) ;
28
28
29
29
if ( props . line . timeInMs >= current ) return 'upcoming' ;
30
30
if ( current - props . line . timeInMs >= props . line . duration ) return 'previous' ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ export type SyncedLyricsPluginConfig = {
4
4
enabled : boolean ;
5
5
preciseTiming : boolean ;
6
6
showTimeCodes : boolean ;
7
+ lyricsOffset : number ;
7
8
defaultTextString : string ;
8
9
showLyricsEvenIfInexact : boolean ;
9
10
lineEffect : LineEffect ;
You can’t perform that action at this time.
0 commit comments