Results 1 to 9 of 9

Thread: Working with iTunes API

  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

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Working with iTunes API

    Maybe u shouldn't use App
    VB Code:
    1. Public App  As iTunesApp
    as its a VB property.

  3. #3

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

    Re: Working with iTunes API

    Great idea. Thanks.

    Unfourtunately I am still getting the same error.
    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

  4. #4
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Working with iTunes API

    VB Code:
    1. Call App.ConvertFiles(FileNames)
    should this be
    VB Code:
    1. Call App.ConvertFiles(FileNames(0))
    ?? I don't have Itunes so i can't really try it.

  5. #5
    Member AWC_Joe's Avatar
    Join Date
    Jan 2006
    Location
    Located
    Posts
    49

    Re: Working with iTunes API

    I was looking to do the same thing awhile back... i think you have a small task on your hands. From what ive read (and played with) the info you want to save/edit is held in the .DS_Store file stored on the Ipods harddrive. The file is in binary, heres a link to a site with info on how the file is structured, with the offset and size values:
    http://ipodlinux.org/ITunesDB

    If you search http://www.planet-source-code.com for "iTunes" you file a few examples of pulling the info from the ITunesDB.


    _
    |
    Some programs and scripts ive made: http://wiki.anotherwebcom.com
    What was once an opinion, became a fact, to be later proven wrong...

  6. #6

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

    Re: Working with iTunes API

    Andrew G,

    In the JScript example I posted they pass the entire array. So that is what I was trying to do. Passing just a string (or an element of an array) still gives me the "Invalid [rocedure call or agument" error.

    ACW_Joe,

    I think you misunderstood what I was after. I don't want to get the info. I want to simply add a song to iTunes. I want to acheive the same effect as if you drag-n-dropped a song into iTunes. All I need is to add it to the iTunes library. I was thinking convert files would do that.
    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

  7. #7
    Member AWC_Joe's Avatar
    Join Date
    Jan 2006
    Location
    Located
    Posts
    49

    Re: Working with iTunes API

    Ohh.. sorry about that.
    I thouhgt you wanted to add the mp3s to your Ipod and by-pass iTunes all togeather.
    |
    Some programs and scripts ive made: http://wiki.anotherwebcom.com
    What was once an opinion, became a fact, to be later proven wrong...

  8. #8

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

    Re: Working with iTunes API

    Can anyone else help on this topic?
    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

  9. #9

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

    Re: Working with iTunes API

    Incase anyone is wondering, I figured out how to do the conversion. I couldn't get it to work with multiple files at once, but to do one file at a time use this:
    VB Code:
    1. App.LibraryPlaylist.AddFile("Path_here")
    Where App is an iTunesLib.iTunesApp object.
    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