0

我知道如何按名称播放播放列表中的歌曲,但可以说我想制作它,以便在播放该歌曲时空格和大小写无关紧要。

所以如果我想播放“someSong”、“some song”或“Some Song”,我仍然想在我的播放列表中播放一首名为“Some song”的歌曲。

我怎么做?

4

1 回答 1

0

尝试:

set yourSong to "yoursongname"
set yourPlaylist to "your playlist"

set searchString to {}
repeat with i from 1 to count of yourSong
    set aChar to text i of yourSong
    if aChar ≠ space then
        set end of searchString to aChar & " *?"
    end if
end repeat
set searchString to searchString as text

tell application "iTunes" to set plTracks to name of every track of playlist yourPlaylist
set AppleScript's text item delimiters to linefeed
set plTracks to plTracks as text
set AppleScript's text item delimiters to {""}
set targetSong to do shell script "echo " & quoted form of plTracks & " | grep -Ei " & quoted form of searchString

log targetSong
display dialog "Now Playing: " & targetSong buttons {"Cancel", "OK"} default button "OK" giving up after 2

tell application "iTunes" to play track targetSong of playlist yourPlaylist
于 2012-11-18T05:36:03.003 回答