I'm looking for a way to automatically add mp3 files to a itunes
playlist, each time a new mp3 file is saved into a folder.

This is what we use in our CoverBuddy:


Function GetPlaylistRef(inPly As String) As AppleEventObjectSpecifier
   Dim aa As AppleEvent

   aa = NewAppleEvent("core", "getd", "hook")
aa.ObjectSpecifierParam("----") = GetNamedObjectDescriptor ("cPly", nil, inPly)
   If (aa.Send) Then
      Return aa.ReplyObjectSpecifier
   End If

End Function

Sub AddTrackToPlaylist(inTrack As FolderItem, inPly As String)
   //Add track given by folderitems to playlist

   #pragma DisableBoundsChecking

   Dim ae As AppleEvent

   ae = NewAppleEvent("hook", "Add ", "hook")
   ae.FolderItemParam("----") = inTrack
   ae.objectSpecifierParam("insh") = GetPlaylistRef(inPly)
   ae.Timeout = 1
   If (Not ae.Send) Then
      AEError
   End If

End Sub


If you need to add more than one:

Sub AddTracksToPlaylist(inTracks() As FolderItem, inPly As String)
   //Add tracks given by array of folderitems to playlist

   #pragma DisableBoundsChecking

   Dim ae As AppleEvent
   Dim list As New AppleEventDescList
   Dim i, j As Integer

   ae = NewAppleEvent("hook", "Add ", "hook")
   j = Ubound(inTracks)
   For i = 0 To j
      list.AppendFolderItem inTracks(i)
   Next
   ae.DescListParam("----") = list
   ae.objectSpecifierParam("insh") = GetPlaylistRef(inPly)
   ae.Timeout = 1
   If (Not ae.Send) Then
      AEError
   End If

End Sub



Simply pass the folderitem(s) and the name of the playlist.


You should use AppleEvents instead of AppleScript – this will be much faster.

Hope that helps,
--
Jörg

____________________________________________
three-2-one interaktive Medien GmbH

[EMAIL PROTECTED]
http://www.three-2-one.com
fon: +49 2151 31945-11




_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to