【问题标题】:Preview songs in Spotify with Applescript - NeedleDrop from Doug使用 Applescript 在 Spotify 中预览歌曲 - Doug 的 NeedleDrop
【发布时间】:2014-07-12 11:30:02
【问题描述】:

我们都知道 Doug 的 iTunes 应用程序脚本。但是,随着流媒体音乐的增长,我不再使用 iTunes,而是使用 Spotify。

我试图调整 NeedleDrop 脚本来预览歌曲。该脚本允许设置

a - 从给定时间开始,f.e. 30 秒后开始播放歌曲 b - 在给定的时间内播放该歌曲,f.e. 10 秒。

问题是脚本在给定时间开始第一首歌曲并播放给定时间,但是接下来的歌曲播放给定时间,但从头开始而不是给定时间值。

该脚本在 Doug 的 GNU 许可下,并且包含该许可。 我正在发布脚本和从中导出的应用程序。如果有人有想法?!

链接:Download

这是下载文件中提供的脚本:

-- handler to get a number from user
to get_a_number(pmpt, addenda, defnum)
    set rez to (display dialog addenda & pmpt default answer defnum buttons {"Cancel ", "OK"}          default button 2 with title "Needle Drop")
    if button returned of rez starts with "cancel" then tell me to quit
    set myNumber to text returned of rez
    try
        if myNumber is "" then get_a_number(pmpt, "Enter only numbers..." & return & return, defnum)
        return (myNumber as integer)
    on error -- m number n
        get_a_number(pmpt, "Enter only numbers..." & return & return, defnum)
    end try
end get_a_number

global start_time -- seconds into each track to begin playing
global needle_drop_interval -- seconds to play each track

on run
-- get number of seconds between songs
    set needle_drop_interval to my get_a_number("Play each track for how many seconds?", "", "10")
-- get seconds into each track to play
    set start_time to my get_a_number("How many seconds into each track to start playing?", "", "10")

-- play first song in the playlist
    tell application "Spotify"
        activate
        set player position to start_time
        play
        delay needle_drop_interval
    end tell
end run

on idle
    tell application "Spotify"
        if player state is not playing then tell me to quit
        pause
        next track
        set player position to start_time
        play
    end tell
return needle_drop_interval
end idle

on quit
    try
        tell application "Spotify" to stop
    end try
    continue quit
    error number -128
end quit

【问题讨论】:

    标签: applescript itunes spotify preview


    【解决方案1】:

    提供的脚本适用于离线播放列表,但不适用于流式播放列表。 Spotify 可能没有时间缓冲曲目或其他内容。

    当我添加延迟以给 spotify 时间缓冲时,它工作正常。 (您可以尝试更短和更长的延迟)

    tell application "Spotify"
        if player state is not playing then tell me to quit
        next track
        pause
        set player position to start_time
        delay 1
        play
    end tell
    

    注意“下一首”和“暂停”之间的行切换

    【讨论】:

    • 对不起,我对 Stack 很陌生,所以我无法投票赞成你的答案。回答了主要问题。谢谢和欢呼
    • 我在我的网站上分发了这个小应用程序,并感谢您的帮助。如果您愿意,我可以将其删除或更改为任何其他链接。干杯 -> bodysoulspirit.weebly.com/prefy.html
    【解决方案2】:

    太棒了!

    但是,在播放了一些歌曲之后,有时仍然会出现该错误,通过在设置的播放器位置之前添加延迟似乎可以完全修复。

    这听起来可能矛盾,但对我来说效果更好。

    谢谢!

    on idle
        tell application "Spotify"
            if player state is not playing then tell me to quit
            next track
            pause
            delay 1
            set player position to start_time
            play
        end tell
        return needle_drop_interval
    end idle
    

    【讨论】:

      猜你喜欢
      • 2018-03-27
      • 1970-01-01
      • 2012-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-11
      • 2011-11-30
      • 2019-09-12
      相关资源
      最近更新 更多