AppleScript to play playlist starting at certain track not functioning as expected...

I'm trying to write an AppleScript that scans a playlist called "iMac Shuffle" and finds the last song that was played in the playlist by comparing the last played date of the next track to see if it is less than the current track, in which case play that track. This is my code so far:
tell application "iTunes"
     set i to 1
     repeat while played date of track i in playlist "iMac Shuffle" < played date of track (i + 1) in playlist "iMac Shuffle"
          set i to (i + 1)
     end repeat
     reveal track (i + 1) in playlist "iMac Shuffle"
     play track (i + 1) in playlist "iMac Shuffle"
end tell
It finds the correct track and begins playing, but when the track ends, it always seems to skip to the song after the last tracked I manually started playing.
For example, I manually played track 3 but paused it halfway through. I ran my script and track 6 started playing, which is correct according to the last played date, so all is well. However, when track 6 ends, instead of track 7 playing, track 4 begins.
This is incredibly frustrating. Does anyone know why this is happening?

This is, I think, the expected behavior. If itunes is playing a playlist, and applescript interrupts to play a different song, then next track ought to send it back to the next track in the playlist before the interruption, not the next track after the interruption. The workaround is not to use the next track command, but specify tracks directly.  i.e.:
tell application "iTunes"
          set t to (get selection)
          repeat with i from 1 to 5
                    play item i of t
                    repeat until player position > 3
                              delay 1
                    end repeat
          end repeat
  stop
end tell

Similar Messages

  • Data Tracking not working as expected

    Hi,
    I have created a report on a universe which is based on a BEx Query. When I run the WebI report in InfoView saved data shown, I then select tracking and select the current data (fixed) as the reference data. I then enter a key date for the data (which effively looks at data at a point in time) and the data changes but the changes are not marked. However, the reference date at the bottom of infoview is the saved data date.
    I then refresh the data again and change the key date to a different date and changes are shown based on the data which I refreshed in the report NOT the saved data. I have had a look at the bottom of infoview and the data tracking reference date changed to the REFRESHED data. I then refreshed it again and the reference date remains as the refreshed data.
    Just to re-confirm I did select use Fixed reference data.
    Any ideas why I am having this problem?
    Thanks

    Hi,
    The key date is in the SAP BW BEx Query which the universe is created on. The WebI report is then created on that universe. The key date changes the data.
    I have just tried loading the data into SAP BW so that the data changes. I then went to the WebI report which is showing the old data and has tracking on by default when the report was created. the fixed data date at the bottom says the old date. I then refresh the new data is shown and the fixed data date changes....tracking is still not working as we expect.
    Any ideas
    Thanks

  • Copy / Paste Audio track not functional?

    I have Quicktime 7 with the MPEG option. I can open mpeg-2 video files and edit them. I can open mpeg audio files but I can not edit them.
    How do I take an Mpeg audio track and add it to an Mpeg video track?
    I tried to folow the instructions here:
    http://docs.info.apple.com/article.html?path=QuickTime%20Player/7.0/en/c3qt7.htm l
    However, at step 2 where it states "Edit * Copy", the option is not available. I can madly click all I want on the greyed option but it doesn't copy the audio track.

    Adrian. I apologize for the bum advice. I bounce back between the Mac and Windows pages and sometimes fail to notice where I am.
    The MPEG editing features are the same for both the Mac and PC versions. QuickTime can't edit muxed track files. It never could.
    There are some known issues (Mac side anyway) about AC3 audio. The third party codec isn't properly supported by QuickTime 7.0.2.
    There is probably a PC software that works similar to MPEG Streamclip.
    http://www.virtualdub.org/

  • Won't play songs and music store is not functioning properly

    I downloaded iTunes 6.02 today and it took a lot of work to even get into the program.
    But now the songs will not play when play is pushed and the music store will come up but there will be no pictures on it.
    I tried iTunes for Windows: Audio files do not play in iTunes 5 or 6 but I did not have the compatibility box checked so I am at a loss as to what to do next, and I have no idea on how to fix the music store.
    Plz help.
    Thank you.
    Dell Inspiron 9300   Windows XP Pro  

    I'm going through exactly the same thing. I keep writing back and forth to apple and they are not coming up with any answers. I'm giving up and going to Rhapsody. I hope they figure yours out.

  • My note 2 just started locking up and not functioning properly out of the blue...any advice.

    My note 2 has been working great for over a year without any issues. This morning it locked up for the first time and is now having problems. Very slow response times and just not working as it should.
    Any advice out there. Anyone else having issues today?

        Smwmustang,
    Lets get your phone up and running again! Now that it's been a couple days, how is it responding? If it's still slow you can try the steps in our amazing Trouble Shooting Assistant http://vz.to/1grhkqT to get  things going again. Let us know if the steps there do not work, and we'll be happy to do some advanced trouble shooting with you.
    SarahO_VZW
    Follow us on Twitter @VZWSupport

  • Firefox start/search page will not function.

    I still use the Firefox search page as my home page. When I attempt to use this system nothing happens. I will type in what I am trying to search, hit enter or click search. and it is though the page does not recognize any of my triggers to the page. The cursor does turn into a small hand when I scroll over the search button, it just doesn't respond when I try to trigger it. I do not recall the update that made this happen as I only recently was able to remove an anti-virus program that defaulted my search page to its service rather than that of Firefox.

    Is this about the about:home page?
    Try to reset some preferences to the default with the SearchReset extension:
    *https://addons.mozilla.org/firefox/addon/searchreset/
    Note that the SearchReset extension only runs once and then uninstalls automatically, so it won't show on the "Firefox > Add-ons" page (about:addons).
    Check the <b>browser.search.defaultenginename</b> pref on the about:config page and make sure that it is set to the default value Google.
    *browser.search.defaultenginename
    *http://kb.mozillazine.org/about:config
    If there is a problem with searching via the default about:home page then try to reset the search engine used on the about:home page.
    Reset the <b>browser.startup.homepage_override.mstone</b> pref via the right-click context menu to the default on the <b>about:config</b> page and close and restart Firefox to restore the about:home page to its default.
    *http://kb.mozillazine.org/about:config
    #Open the <b>about:config</b> page via the location bar
    #Type in the Filter bar: mstone
    #Right-click the browser.startup.homepage_override.mstone line and select: Reset
    #Close and restart Firefox
    If this didn't help then delete the delete the chromeappsstore.sqlite file in the Firefox Profile Folder and repeat the above.

  • Auto find tracks not in playlists and delete them?

    Is thre any way I can auto find all tracks that are not in any of my playlists and delete them all in one go?

    If you have a look at Dougs AppleScripts there is one that will find tracks not in any playlist.
    You can use that to create a playlist with them in and then do as you will with them.
    Regards,
    Colin R.
    Message was edited by: Colin Robinson
    http://www.dougscripts.com/itunes/
    Message was edited by: Colin Robinson
    http://www.dougscripts.com/itunes/scripts/scripts01.php?page=1#notinanyplaylist

  • Liquid spill on keyboard. Certain keys not working. Any inexpensive repair? re

    Water spill on the keyboard of my Mac Book Air. Now certain keys not functioning. A Mac friend suggested submerging in rice upside down to dry out. Didn't work. Warranty expired. Help!

    Yes, the "magic rice trick" doesnt work.
    inexpensive repair? No.
    Liquid spills, why your MacBook chassis is a one-way valve for spills
    After a substantial spill many people will turn their notebook upside down and shake it, not only does this not work, but it spreads liquid havoc throughout your machine and makes things often as bad as possible.
    The keyboard itself acts like a one way valve in the case of a substantial liquid spill. While liquid pours into the bottom chassis easy, it does not come out easily at all, and in the case of any spill, most of it will not come out by turning it upside down. Disconnect all power and contact Apple for diagnostics and repair.
    Do not attempt to, after a spill, ‘dry out your MacBook’ and test it
    After a spill most people invariably try to “dry out” their notebook by various methods, including hair dryers and otherwise. This both does not work, and after a substantial spill of any magnitude, even if the liquid was water, residue is left behind.
    There are additionally many very tight places inside your notebook where liquids will linger for a very long time, and cause corrosion or worse.
    Immediately unplug your notebook and contact Apple for in shop diagnostics and parts replacement.
    In the case of very minor spills people will “dry out” their notebook and feel success that their notebook is working ok, however invariably in nearly all instances after 4-14 days an error / fault pops up and is usually followed by more.
    In case of a spill, damage estimates are impossible,.....anything can be fixed, without question.......the question is cost.
    contact Apple for in shop diagnostics and cost estimation ....possible parts replacement.  

  • My iTunes doesn't keep track of my listening history anymore. It doesn't update play counts and default "Recently Played" playlist.

    My iTunes doesn't keep track of my listening history anymore. It doesn't update play counts and default "Recently Played" playlist. But it still tracking plays from my iPhone and syncing them.
    I've tried to repair it with setup file. Nothing's changed.
    Can you help me with that?
    NOTE: Now I tried disabling the crossfade feature and it worked, started to count again. But I like crossfade, I don't want to keep it off.

    I think I got this figured out. The playcount does update, but not how the previous iPod models update their playcount. Instead of immediately updating the playcount right after you finish the song like the older iPod models, iPod Touch keeps the updates in memory. The next time you connect to iTunes it'll sync those playcounts in memory to the actual songs itself, effectively updating the playcount of the songs only after connecting to iTunes. I have set my syncing manually. That's why after connecting to iTunes, my playcounts are updated. BUT it doesn't solve the mystery of my Smart Playlist. Even though in iTunes, the correct songs are listed, in the iPod Touch, it shows the old playlist.
    Don't you just hate that? It was working fine before on non-iPod touch models. Now we have to live with this new bug. I just hope when they release software 2.0 it fixes these bugs and that they *give it for free!* People shouldn't be charged on something they should have gotten as a support!

  • Logic wont play back audio regions under certain tracks.

    Hello! I am rearranging my audio files (throwing them all to my secondary hard drive, where I record to ). I did this, and now certain audio files to do not play back in my logic projects, but there is no warning that says the file cannot be found--which is what I am used to happening. At that point I would either hit the Search button, or the Manually Find button. Instead, the region appears as per usual, just with nothing playing back. I know I could import the audio back into my projects manually--which would be fine for those that start at a specific, clean-cut time, but what about all those spliced and diced regions that are cut up and laid out all over the place!?
    I discovered new details to the weirdness . . .
    It seems, in the few projects that I relocated audio, that the affected regions cannot be played back unless I move them to another audio track. What??? For example, the vocal track in one song, which is all set up with its plugins and such as Audio Track 2, will produce no sound unless I drag it to another audio track, say Audio Track 3 or 4. It is bonkers!! What the heck is that about?
    This is what happened in all of the projects affected by my source audio rearrangement. Sure, I could easily just copy my channel strip settings to a new track, relocate my audio region to it, and hope all goes well thereforth, but I would much rather get to the root of this oddity so it doesn't somehow buck me later.
    What do you think it could be?
    Oh yea, in one of the projects, all the other audio tracks seem to play back fine, except for the recorded bass track. Okay, so just to check, I drag the bass audio to another track--yep, it does play back. But I realized that the track that held the bass region (Track 4) is actually playing back the vocals (which are also playing back normally in their intended track). I initially didn't notice the extra vocals underneath my normal vocals track, with their low-key bass plug-in settings. Funny thing is, there isn't even a region on Track 4 any more! How is it playing anything back at all?? Not that it makes any more sense that it would be playing back vocals with a bass region.
    Also, the fact that Logic Pro keeps quitting unexpectedly does not inspire much confidence. This has just been lately, and I've only been playing with these projects lately, trying to figure this out.
    Is my Logic haunted? =(
    I welcome any and all objective suggestions! I am feeling just the slightest bit overwhelmed by this odd behavior.
    Thanks!
    (i checked, but did not see that the tracks were muted in anyway, including the region itself)

    I figured something out that might tell someone what I did to screw things up!
    I think I did something to mess up the environment or something. I know this much now: When I created a new project, I created 6 new audio tracks. I noticed that a piece of previously recorded audio that I imported into the project would only play back on ever other track! I than noticed that on the every other track (that would not play back the audio when it was dragged to it), there was neither a single circle (indicating mono for the track) or the two overlapping circles (indicating stereo for the track) beneath the channel's level meter.
    There must be some significance to this that I do not quite understand!
    I then went back and launched several of my problematic projects to see if the tracks that would not play back audio also did not display either the mono or stereo circles on their respective channel strips. They did not! What kind of global setting did I change that would cause this?
    There was one project that had one track that bared neither mono or stereo an played back its audio (Although, in this same project, there was another track that bared neither symbol that was not playing back its audio). Anyway, I noticed something that was weird to me, but will likely tell someone what the heck I must have inadvertently done to cause all of this:
    When I change one audio track (that bares the mono symbol) into stereo, the next audio track (that didn't display either symbol) seems like it is combined with the previous track's output!
    Very strange! Did I somehow set some global preference to split up my audio tracks across each not audio track?? If so, could someone please explain to me what and I did that? Thanks!

  • ITunes will only play one song. I have to hit play to start a new song. I have the shuffle on and I am in a playlist. I am running Windows 7. How do  I correct this to randomly play music, by itself?

    iTunes will only play one song. I have to hit play to start a new song. I have the shuffle on and I am in a playlist. I am running Windows 7. How do I correct this to randomly play music, by itself?

    That's consistent with all the tickboxes to the left of the tracks (in Song view) being unchecked.
    Go into Song view and Ctrl-click one of the empty boxes to do a "global recheck".
    If you can't see the tickboxes, head into your General preferences tab and select "Show list tickboxes" as per the following screenshot (it's for an earlier version of iTunes, but the boxes are in roughly the same place in the recent versions 11.x):

  • ITunes starts fast forwarding tracks after 1hours continuous play?

    Hi I have recently updated windows XP on my computer to service pack three. After this update when I am listening to iTunes it suddenly started playing the songs in my library too quickly as if it was stuck on fast forward.
    If you stop itunes playing then press play or select a different track it continues to play too fast. The only way to fix the problem is to close itunes and re-open it.
    I have now found that this problem starts after iTunes has been playing music for just over an hour, so currently I'm having to close and re-open itunes ever hour to keep listening to music.
    Any Idea why this might be happening?
    I'm running XP SP3, 3GB ram, 3GHz processor, 200GB HD no where near full. Its iTunes version 8.2.1.6.
    Thanks
    Liam
    Message was edited by: Liamom_uk

    Anyone else have this problem? I have now timed the problem to exactly 1hour 9minutes of continuous play, so if you play for 30 mins, pause for 15 then play iTunes starts fastforwarding 39 minutes later.

  • The ipad music app does not allow me to play certain tracks that i have synced via my itunes. The tracks are clearly visibly in the music app but when tap on them to play they wont play. help and advice will be much appreciated

    The ipad music app does not allow me to play certain tracks that i have synced via my itunes. The tracks are clearly visibly in the music app but when tap on them to play they wont play. what do i do?

    Agree about the disaster part. I haven't found a fix within iTunes.
    I gave up and switched to downcast 2 days ago. Even though it was a hassle to re-subscribe to all my podcasts, im so much happier.
    To make switching easier, I found that in iTunes you can "get info" on the podcast and copy the RSS address to the clipboard. Put all of these in a message note. When iCloud syncs the note to your phone, you can copy and paste the urls into downcast one at a time to subscribe.
    Downcast has crashed on me occassionally when I'm subscribing to feeds, but so far it has recovered gracefully each time and no data was lost.

  • Every time I press play or reset back to the start of my track the levels in the mix reset themselves to default levels

    Ive just purchase logic and immediately loaded a midi file from an iPad app called MusicStudio. All fine except when I try to set a balance between the tracks in the mixer or using the inspector all the levels return to there original positions when I return to the start of the track. Im I missing something simple? help

    Region (or MIDI) automation.  Open the event list, find CC#7 events - probably be one at the top of the list - and delete.

  • Can 'track list' button show your playlist rather than album track list?

    Hi all
    My 3GS iPhone has my music on it in the form of whole albums which live in individual playlists on my Mac, but I also have playlist 'mixes' which I've created from various songs from multiple albums.
    When selecting to play a 'mixed' playlist on my iPhone I tap on it, tap the first song to start the music playing, but then if I tap the top right 'track list' button, instead of showing all the tracks in my created playlist it just shows the entire album tracks from where this particular song has come from. Visually I prefer the 'track list' screen but it seems I can't use it if I'm playing a 'mixed' playlist. Is there any way around this?
    Also, this is the same if I have a double CD album: once I hit the 'track list' button it shows just CD 1 (or 2 if I'm further down the play list of course), rather than all the tracks even though on they all live in one single playlist on my iTunes. I've even taken the starts of the track names off (some of them start with '1_01 Song Title' for example) when importing them into iTunes to see if that helps but it doesn't: the iPhone KNOWS how that track was originally supplied!
    Any help or clarification on this would be very helpful!
    Markos

    sadly, that kind of customization is only easily doable on a computer. the iPhone and it's core apps can not be changed by users. you can request the feature be put in, but unless there are a LOT of requests, you shouldn't get your hopes up as there are a lot of these kinds of requests, and by implementing it, how many other users would be angry and demand it be changed back? http://www.apple.com/feedback/
    if you are playing a song that you selected in a playlist, you should be able to hit the 'back' button in the top left to go back to the playlist and view your songs in the playlist.
    in regards to the 'cd 1 of 2' thing, you will need to change your song info to get this to show in the format you want. to see the song info, select a song and go to 'file -> get info'. that will show you all of the ID3 tag information, which you can edit to do whatever you want.

Maybe you are looking for