Results 1 to 9 of 9

Thread: Working with iTunes API

Threaded View

  1. #1

    Thread Starter
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Working with iTunes API

    I am trying to hack together a quick little program that will automatically add any song in a folder directly to iTunes without dragging and dropping. I am not very familiar with the iTunes API/COM/Whatever-the-heck-it-is.

    I found some examples online, but they were in WScript or something. When I run my code, I get an "invalid procedure call or argument" on the "ConvertFiles" line. Here is what I came up with:
    VB Code:
    1. Option Explicit
    2.  
    3. Public App  As iTunesApp
    4. Public FSO  As FileSystemObject
    5.  
    6. Private Sub Command1_Click()
    7.     Dim FileNames(0)
    8.    
    9.     FileNames(0) = FSO.GetAbsolutePathName("C:\Documents and Settings\Bob\Desktop\AAA.mp3")
    10.     Call App.ConvertFiles(FileNames)
    11.    
    12.    
    13. End Sub
    14.  
    15. Private Sub Form_Load()
    16.     Set App = New iTunesApp
    17.     Set FSO = New FileSystemObject
    18. End Sub
    I don't really want to convert files to another format, but that function was the only thing that looked close to what I wanted.

    Here is what the WScript (or JScript or whatever the heck it is) looked like. Maybe someone can translate. It looks like it is being put in an array and the array is being passed.
    Code:
    http://www.hydrogenaudio.org/forums/index.php?showtopic=21736&st=0&&
    args = WScript.Arguments;
    
    if  (args.length != 0) {
    
    var iTunesApp = WScript.CreateObject("iTunes.Application");
    var  encoderCollection = iTunesApp.Encoders;
    var encoder=encoderCollection.ItemByName("AAC Encoder");
    iTunesApp.CurrentEncoder = encoder;
    var  fso = new ActiveXObject("Scripting.FileSystemObject");
    fil = new Array();
    for (i = 0; i < args.length; i++) {
     fil.push(fso.GetAbsolutePathName(args(i)));
    }
    iTunesApp.ConvertFiles(fil);
    }
    
    else {
    WScript.Echo("Usage: encodeAAC.js <filename.wav>");
    }
    Last edited by eyeRmonkey; Feb 18th, 2006 at 03:34 AM.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width