|
-
Feb 17th, 2006, 10:55 PM
#1
Thread Starter
No place like 127.0.0.1
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:
Option Explicit
Public App As iTunesApp
Public FSO As FileSystemObject
Private Sub Command1_Click()
Dim FileNames(0)
FileNames(0) = FSO.GetAbsolutePathName("C:\Documents and Settings\Bob\Desktop\AAA.mp3")
Call App.ConvertFiles(FileNames)
End Sub
Private Sub Form_Load()
Set App = New iTunesApp
Set FSO = New FileSystemObject
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.
-
Feb 18th, 2006, 03:05 AM
#2
Re: Working with iTunes API
Maybe u shouldn't use App as its a VB property.
-
Feb 18th, 2006, 03:33 AM
#3
Thread Starter
No place like 127.0.0.1
Re: Working with iTunes API
Great idea. Thanks. 
Unfourtunately I am still getting the same error.
-
Feb 18th, 2006, 10:03 PM
#4
Re: Working with iTunes API
VB Code:
Call App.ConvertFiles(FileNames)
should this be
VB Code:
Call App.ConvertFiles(FileNames(0))
?? I don't have Itunes so i can't really try it.
-
Feb 18th, 2006, 11:00 PM
#5
Member
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.
_
-
Feb 19th, 2006, 02:07 AM
#6
Thread Starter
No place like 127.0.0.1
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.
-
Feb 19th, 2006, 05:25 AM
#7
Member
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.
-
Feb 20th, 2006, 01:50 PM
#8
Thread Starter
No place like 127.0.0.1
Re: Working with iTunes API
Can anyone else help on this topic?
-
Mar 9th, 2006, 11:10 PM
#9
Thread Starter
No place like 127.0.0.1
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:
App.LibraryPlaylist.AddFile("Path_here")
Where App is an iTunesLib.iTunesApp object.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|