Hi,

I'm trying to tell iTunes to convert a file as mp3. I can tell it to  
convert, but I need to handle the result.
So far, I have this code:

Function ConvertFile(File As FolderItem) As FolderItem

   dim ae As AppleEvent


//Send the 'convert' AppleEvent:
   ae=NewAppleEvent("hook","Conv","hook")
   ae.FolderItemParam("----")=File
   ae.Timeout=99999
   if not ae.Send then
     msgbox "iTunes is not running."
     return nil
   end if
//Equivalent to 'tell app "iTunes" to convert TheFile'

//Now that the file has been converted, the ae.result is the  
converted track (appended to the library). I don't know what to put  
next (In AppleScript, I'd do that: 'tell app "iTunes" to get location  
of result').
end function

Using AEMonitor, I have this piece of code as the returned result:

Function AEMSendAE() as AppleEvent
Dim AEDescList as AppleEventDescList
Dim aeobjref as AppleEventObjectSpecifier
Dim aeobjref1 as AppleEventObjectSpecifier
Dim aeobjref2 as AppleEventObjectSpecifier

Dim ae as AppleEvent

ae=NewAppleEvent("aevt", "ansr", "hook") 'Means "reply from iTunes"

AEDescList=new AppleEventDescList

aeobjref2=GetUniqueIDObjectDescriptor("cSrc", nil, "37")
aeobjref1=GetUniqueIDObjectDescriptor("cLiP", aeobjref2, "16655")
aeobjref=GetUniqueIDObjectDescriptor("cFlT", aeobjref1, "43097")
AEDescList.AppendObjectSpecifier(aeobjref)
ae.DescListParam("----")=AEDescList

if ae.send then
return ae
else
return nil
end

End Function

So the above piece of code returns a track. I now have to get the  
location of this result, so I tried  to add that at the end of my  
method:

   dim ae2 As AppleEvent

   ae2=NewAppleEvent("aevt","getd","hook") 'The 'get' AppleEvent
   p=GetPropertyObjectDescriptor(ae.ReplyDescList.ObjectSpecifierItem 
(1),"pLoc") //From the result of the "convert" appleEvent call (i.e  
the track), I want to get the "pLoc" property (i.e the location, the  
file). I don't recall if ObjectSpecifierItem starts at 0 or 1, but I  
tried both.

   ae2.ObjectSpecifierParam("----")=p
   if not ae2.Send then
     msgbox "iTunes is not running (2)."
     return nil
   end if
   dim f As FolderItem
   f=ae2.ReplyFolderItem
   return f

But it does not work.
Can anyone help, please?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to