Skip a few seconds forward/backward in iTunes

Jul 27, '05 08:56:00AM

Contributed by: Blittser

I listen to podcasts within iTunes. Sometimes, I like to skip through some material (e.g. ads or music or whatever). I used two extremely simple AppleScripts that will do just that (forward or backward).

I activate them using iKey, although any macro program would do. The skipped duration can be altered by the user by modifying the scripts.

Skip forward:

tell application "iTunes"
  if player state is playing then
    -- length of current track:
    set trackTime to duration of current track
    --get the current position time:
    set currTime to get player position
    --to set new position to 10 seconds ahead:
    set currSkip to currTime + 10
    
    -- checks if new position is greater than 
    -- length of track, and corrects it if it is:
    if currSkip > trackTime then
      set currSkip to trackTime
    end if
    
    set player position to currSkip --skip to new position
  end if
end tell
Skip backward:
tell application "iTunes"
  if player state is playing then
    --get the current track time:
    set currTime to get player position
    --if track is less than 10 seconds:
    if currTime < 10 then
      --go to start of the track:
      set currSkip to 0
    else
      --otherwise, skip backwards 10 seconds:
      set currSkip to currTime - 10
    end if
    
    set player position to currSkip --skip to new position
  end if
  
end tell
The scripts should work only if iTunes is currently playing a track, and do not work when playing live MP3 streams.

Comments (9)


Mac OS X Hints
http://hints.macworld.com/article.php?story=200507192227372