1
我試圖製作一個告訴iTunes播放某個曲目的AppleScript。這是我的代碼。我很困惑,因爲當我將「命令」設置爲「由藝術家列車播放動搖聖誕節」時,當我右鍵單擊測試電子郵件並單擊「應用規則」時,該腳本起作用。但是,當我告訴它播放電子郵件告訴它播放的內容時,它不起作用。爲什麼我的AppleScript程序會說iTunes在實際上並沒有這樣做時正在播放曲目?
using terms from application "Mail"
on perform mail action with messages messageList for rule aRule
tell application "Mail"
repeat with thisMessage in messageList
try
set theCommand to content of thisMessage as string
on error errMsg
display alert errMsg
end try
end repeat
end tell
tell application "iTunes"
if theCommand contains "play" then
if theCommand is equal to "play" then
play
else
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to "play "
set subject to text items of theCommand
set text item delimiters of AppleScript to ""
set subject to "" & subject
set AppleScript's text item delimiters to " by artist "
set delimitedList to every text item of subject
set theTrack to the first item of delimitedList
try
set theArtist to the second item of delimitedList
set artistIsDefined to true
on error
set artistIsDefined to false
end try
set AppleScript's text item delimiters to prevTIDs
if artistIsDefined is true then
try
play (every track in playlist 1 whose artist is theArtist and name is theTrack)
say "Playing " & theTrack
on error errMsg
say errMsg
end try
else
play (every track in playlist 1 whose name is theTrack)
end if
end if
else if theCommand is equal to "pause" then
pause {}
else if theCommand is equal to "stop" then
stop {}
end if
end tell
end perform mail action with messages
end using terms from
MAC將通過說電子郵件迴應「播放(軌道),」但它不會播放的曲目。該文件在Time Capsule上的事實應該無關緊要,因爲iTunes可以訪問它。 (iTunes會在曲目名稱左側顯示感嘆號,如果它不能)。
從4年前就已經有了一個可以接受的答案。它不能解決你的問題嗎?如果沒有,請告訴我們缺少什麼。 – mklement0
@ mklement0我想要人們上傳或下載我的問題 – moonman239
這不是什麼賞金。賞金並不是爲了增加人氣(只有谷歌平局的運氣,也許像你的個人博客可以幫助那樣),但尋找解決方案來解決未解決的問題。順便說一句:在你的情況下,你會獎勵你的獎金給誰? – mklement0