ddddxxx / LyricsX

🎶 Ultimate lyrics app for macOS.
Mozilla Public License 2.0
4.62k stars 382 forks source link

macOS 14.2 貌似 Spotify 歌词会慢个半句这样 #617

Open DDDD2000 opened 6 months ago

DDDD2000 commented 6 months ago

Apple Music 还是正常的

scuzniverse commented 5 months ago

我好像也是

aviwad commented 2 months ago

Does this only happen when songs autoplay? Like the next song automatically plays? Does pause & playing fix the lag? Because I am facing the same problem in my project https://github.com/aviwad/LyricFever. Was looking here to see if @ddddxxx did anything to fix that

rqhu1995 commented 2 months ago

Does this only happen when songs autoplay? Like the next song automatically plays? Does pause & playing fix the lag? Because I am facing the same problem in my project https://github.com/aviwad/LyricFever. Was looking here to see if @ddddxxx did anything to fix that

Yes, normally if you open Spotify and play the first song after opening the app, there is no lag. Starting from the second song (autoplay), the lag appears. Manually playing another by double clicking a song in the app / pausing and playing / clicking the progress bar of the song can eliminate the lag.

aviwad commented 2 months ago

Yes I fixed this problem in my app 😃. The solution is to send an apple script play command on new song to fix the lyric drift. My app will have an update fixing the bug in 1 week time. Will comment here again on the update. Hope you try it 😄

rqhu1995 commented 1 month ago

Yes I fixed this problem in my app 😃. The solution is to send an apple script play command on new song to fix the lyric drift. My app will have an update fixing the bug in 1 week time. Will comment here again on the update. Hope you try it 😄

根据这位朋友的提示,用macOS自带的“自动操作”和AppleScript,在每首歌播完切换到下一首后,向Spotify强制发送一个“暂停”+“播放”的指令。这样可以触发LyricsX回到正轨。

property appName : "Spotify+"
property spotifyRunning : false

on run
    -- Launch Spotify
    if not application "Spotify" is running then
        tell application "Spotify" to activate
    end if

    set spotifyRunning to true
    my monitorSpotify()
end run

on monitorSpotify()
    repeat while spotifyRunning
        tell application "Spotify"
            if player state is playing then
                set currentTrack to (get name of current track)

                -- Wait for a small interval to check the next song
                delay 1

                if currentTrack is not (get name of current track) then
                    -- Pause and Play to re-sync lyrics
                    pause
                    delay 1
                    play
                end if
            end if
        end tell
        delay 1
    end repeat
end monitorSpotify

on quit
    -- Quit Spotify when quitting the script
    tell application "Spotify" to quit
    set spotifyRunning to false
    continue quit
end quit

on idle
    -- Check if Spotify is running
    if not application "Spotify" is running then
        quit me
    end if

    return 10 -- Check every 10 seconds
end idle

在“自动操作(Automation)”app里,新建一个“应用程序”,然后添加打开LyricsX和Spotify两个操作,之后再添加上面的AppleScript就可以了。

image

P.S. delay的时间或许可以再短点。

aviwad commented 1 month ago

Bro that is a very inefficient solution 💀. Please do not use that. Use my app https://LyricFever.com or you can send a play() command to Spotify via AppleScript. That's all. The play() command corrects the drift.

rqhu1995 commented 1 month ago

Bro that is a very inefficient solution 💀. Please do not use that. Use my app https://LyricFever.com or you can send a play() command to Spotify via AppleScript. That's all. The play() command corrects the drift.

Sorry and thank you for your suggestion.

I've tried LyricFever. It's a super lite and great app but the lyric display can only be at the menubar rather than a floating window. Plus the lyric source depends only on Spotify built-in providers, which is insufficient for many songs.

I'll just modify the AppleScript and use LyricsX for now. Looking forward to the update on LyricFever.