• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Slow script with long lists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Slow script with long lists


  • Subject: Re: Slow script with long lists
  • From: Eric Geoffroy <email@hidden>
  • Date: Wed, 19 Oct 2005 08:47:02 -0700

Matt Neuberg's book has a great tip for a speed boost to list references. p. 259,260
You target a reference to the list instead of the list directly, or more simply just add "my" in front of all of your list references. (except for when you "add to end of list".)


I've used it and it works well.

- Eric

On Oct 18, 2005, at 8:42 PM, Chris Mahn wrote:

Hello,

I have searched the archives to no avail, so I have come here. Please take pity on me before I pull all my hair out!

This script is designed to create a random list of tracks from a playlist (library playlist 1 in this example) in iTunes & play them sequentially, according to this list. However, if the user decides to skip a track or tracks, I want those tracks removed from the random list. This is slightly complicated because when you skip a track in iTunes, the tracks progress numerically. The following is an extreme example: Track 7 begins playing (which is not what you are in the mood for), so you skip the track by hitting the ffwd button moving to track 8 (which is yuck), so you skip to track 9 (yuck), skip to track 10 (ahhh, finally). Well now the tracks 7,8,9,10 must be removed from the playlist, so they are not played again.

The script below achieves this goal, although it does it very very slowly when the list is only moderately long (>300 songs). I shudder to think of it working on 20,000 songs.

Can someone help me make this process happen quickly or at least much quicker?

Cheers, Chris
---script below---
global trk_list
on run
tell application "iTunes"
activate
set trk_list to get index of every track of library playlist 1
--randomize trk_list using HAS "unsortList" subroutine (not included here)


repeat until trk_list is {}
set limit to length of trk_list
set dummyList to {}
play track (item 1 of trk_list) of library playlist 1
delay 10
if index of current track is not (item 1 of trk_list) then
set lst_plyd to index of current track
repeat with i from 1 to limit
set this_item to (item i of trk_list)
if this_item < (item 1 of trk_list) then
copy this_item to end of dummyList
else
if this_item > (index of current track) then
copy this_item to end of dummyList
end if
end if
end repeat
set trk_list to dummyList
log trk_list
else
set trk_list to rest of trk_list
end if
end repeat
log trk_list
end tell
end run
(* using this subroutine, when you skip a track or tracks it will remove those tracks from the master track list & countinue playing the master track list where things left off.
*)
-----------------------

_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Slow script with long lists (From: Chris Mahn <email@hidden>)

  • Prev by Date: New iCal calendar
  • Next by Date: Re: New iCal calendar
  • Previous by thread: Re: Slow script with long lists
  • Next by thread: RE: Slow script with long lists
  • Index(es):
    • Date
    • Thread