AppleScript "enqueue"

Discuss Play, an open source multi-format audio player.
Post Reply
dkagedal
Posts: 18
Joined: Tue Oct 28, 2008 3:13 pm

AppleScript "enqueue"

Post by dkagedal » Sun Nov 23, 2008 1:02 am

I'm trying to figure out how to use the "enqueue" command in AppleScript.

I tried to use an "alias" object to specify the track, like this:

tell application "iTunes" to set f to the location of item 1 of selection
tell application "Play" to enqueue f

But it won't translate an alias to a "track".

I then tried to get some track reference out of Play, but couldn't figure out any way. I'm rather new at AppleScript, so I'm probably misunderstanding something.

I tried to use something like "track 1 of audio library", but it didn't want to give me that.

RonaldPR
Posts: 433
Joined: Tue May 30, 2006 8:27 am
Location: Amsterdam, Netherlands

Re: AppleScript "enqueue"

Post by RonaldPR » Sun Nov 23, 2008 1:46 pm

I think you need to add the file to the library first, before you can add the track to the queue.

dkagedal
Posts: 18
Joined: Tue Oct 28, 2008 3:13 pm

Re: AppleScript "enqueue"

Post by dkagedal » Sun Nov 23, 2008 7:20 pm

Sorry for being unclear. But as far as I can tell, the file is already added to the library.

RonaldPR
Posts: 433
Joined: Tue May 30, 2006 8:27 am
Location: Amsterdam, Netherlands

Re: AppleScript "enqueue"

Post by RonaldPR » Sun Nov 23, 2008 9:23 pm

Why would you start telling iTunes do do something if the file is already in the library. I mean Play library. I am not an AppleScript expert, but I think that the script must add the file to Play library first before it can add the track (to be found in Play library) to Play play queue.

From Play AppleScript dictionary:

enqueuev : Add the specified track to the play queue
    enqueue specifier, track, or list of track : the track(s) to add

addv : Add the specified files to the library
    add file or list of file : the file(s) to add
        [to audio library] : The library for the new object(s)

dkagedal
Posts: 18
Joined: Tue Oct 28, 2008 3:13 pm

Re: AppleScript "enqueue"

Post by dkagedal » Sun Mar 08, 2009 10:48 pm

It is already in my Play library. But I couldn't figure out any way to specify the track to enqueue in the enqueue command. Allow me to quote myself:
dkagedal wrote:I tried to use an "alias" object to specify the track, like this:
...
But it won't translate an alias to a "track".
So getting a track reference from iTunes didn't work. I had hoped that it would recognize that the file name was the same somehow.
dkagedal wrote:I tried to use something like "track 1 of audio library", but it didn't want to give me that.
So I couldn't even figure out how to script the enqueueing of any song from the (Play) library. Do you or anyone else have an AppleScript example that uses enqueue in any way or fashion?

CG
Posts: 37
Joined: Sat Apr 22, 2006 4:44 pm

Re: AppleScript "enqueue"

Post by CG » Sat Jun 13, 2009 12:47 am

This is an old topic, but no solution was ever posted.

How does one enqueue a track that is already in the Play library using Applescript?

Every approach I've tried gives me a different error.

Further, assuming that you need to use the ID of a track for this, how does one get this ID for an AIFF track, since the title and all isn't recognized by the metadata routine in Play?

User avatar
sbooth
Site Admin
Posts: 2445
Joined: Fri Dec 23, 2005 7:45 am
Location: USA
Contact:

Re: AppleScript "enqueue"

Post by sbooth » Sat Jun 13, 2009 4:20 am

I haven't had any luck getting tracks by URL, either. I am no AppleScript expert so it is likely a shortcoming in the scripting dictionary.

CG
Posts: 37
Joined: Sat Apr 22, 2006 4:44 pm

Re: AppleScript "enqueue"

Post by CG » Sat Jun 13, 2009 11:56 am

When the script tells Play to say what file is currently playing, it responds with the integer of the file track ID. From that, it's possible to get the track title and so on. But, there's no way to get the track name as such. So, in the case of aiff files you're left with a bunch of identical files , with the track title of "msng".

For enqueue, I either get an error message along the lines of "type or class not translatable", which is an Applescript problem, or worse I get the response, "Can't get <this track> from audio library." The second means that I'm asking for the wrong thing in the right way.

I'll try getting a track by URL to see what I find out.

CG
Posts: 37
Joined: Sat Apr 22, 2006 4:44 pm

Re: AppleScript "enqueue"

Post by CG » Tue Jun 30, 2009 1:10 am

Well, I made it work.

Here's the AppleScript "code" (you write scripts in AppleScript, you don't write code according to the Apple propaganda) that worked

enqueue track trackCounter in library

where trackCounter is the number of the track in the library.

I'm still working on the URL thing...

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest