2011-09-14 23 views
0

我想要實現的是:Apple腳本:如何獲得iTunes中下一首歌曲的參考?

tell application "iTunes" 
    play next track with once 
end tell 

當然,「下軌」是一個命令,而不是到下一首曲目的引用 - 所以這是行不通的。我已經通過文檔,我真的堅持這一點 - 我將如何編碼,以便它的工作?

如果解決方案涉及製作播放列表或任何沒關係的東西 - 我需要的只是播放下一首歌曲然後停止的腳本。

-

任何幫助是非常讚賞:)我已經浪費了很多時間試圖得到這個工作!

回答

0

多瞎搞之後,這是我正在做。如果你能看到更好的方法,那麼我想知道!

tell application "iTunes" 

    set is_playing to false 

    if player state is playing then 
     set is_playing to true 
    end if 

    tell playlist "Cinderella" 

     set track_number to 1 
     set should_repeat to true 
     repeat while should_repeat is true 

      if track track_number exists then 
       tell track track_number 
        set play_count to (get played count) 
        if play_count is 0 then 
         set should_repeat to false 
        else 
         set track_number to track_number + 1 
        end if 
       end tell 
      else 
       repeat with track_ref in tracks 
        tell track_ref 
         set played count to 0 

        end tell 
       end repeat 
       set track_number to 1 
      end if 
     end repeat 

     if is_playing is true then 
      set played count of track track_number to 1 
      tell application "iTunes" 
       stop 
      end tell 
     else 
      play track track_number with once 
     end if 

    end tell 

end tell 
1

這個腳本是哈克,但它的工作原理...

tell application "iTunes" 
    next track 
    set this_track to the name of the current track 
    previous track 
end tell 
+0

謝謝!這幾乎是這樣的...唯一的一點是,iTunes停止播放後(無法獲取當前曲目),它不起作用 - 我需要它來做:)任何想法如何解決這個問題? –

+0

@Jordan看我的編輯。 – fireshadow52

+0

@感謝,但它有和以前一樣的問題。我已經設法找出解決方案:) –

相關問題