2013-03-30 35 views
2
(歌曲專輯或藝術家)

我正在試圖讓蘋果腳本,理解文本命令「播放的歌曲,我們將搖滾你」或「播放藝術家女王」或「播放專輯之夜在歌劇「播放音樂與變量的AppleScript

使用songName artistName和albumName作爲變量,但我不知道如何設置它們,因爲它們取決於previuos單詞(歌曲,藝術家,專輯)的答案是」播放歌曲名稱「(PLAY必須在現場)。

我知道如何讓他們發揮我只需要設置這些變量,以只使用一個文本框。

感謝您幫助(希望我是清楚的)

+0

始終包括你自己的代碼。我們希望看到一些代碼,以便我們知道您已經嘗試解決該問題。 – apparatix

回答

2

嘗試:

set xxx to text returned of (display dialog "Play song, Play artist, Play album " buttons {"Cancel", "OK"} default button "OK" default answer "Play song Here I Come") 

set myChoices to {"Play song ", "Play artist ", "Play album "} 

tell application "iTunes" 
    repeat with i from 1 to count myChoices 
     set aChoice to (item i of myChoices) 
     if xxx starts with aChoice then 
      set AppleScript's text item delimiters to aChoice 
      set theRest to text items 2 thru -1 of xxx 
      set AppleScript's text item delimiters to {""} 
      set theRest to theRest as text 

      if i = 1 then 
       play (first track whose name = theRest) 
      else if i = 2 then 
       play (first track whose artist = theRest) 
      else if i = 3 then 
       play (first track whose album = theRest) 
      end if 
      exit repeat 
     end if 
    end repeat 
end tell 
+1

非常感謝:) – kuranes

0

您可以使用這樣的事情來獲得輸入:

display dialog "Enter the album name:" default answer "CocoaRocks" 
set the albumName to the text returned of the result 

希望它能幫助。

+0

我需要使用一個文本控件來控制「播放歌曲SONGNAME」「玩藝術家ARTISTNAME」「玩專輯ALBUMNAME」。這就是爲什麼我有麻煩 – kuranes

+0

所以,你需要分析,如「播放歌曲,我的心臟唱」或「播放專輯唱歌之心」這樣你就可以分離出首樂曲或專輯名稱發送到iTunes的字符串。是嗎? (順便說一句:在這裏很好的資源:http://www.macosxautomation.com/applescript/index.html) – 2013-03-30 15:02:59

0

繼承人類似的東西,扮演一個MP3文件

set audioFile to (POSIX path of (choose file of type "mp3")) do shell script "afplay " & audioFile