Jump to content

iTunes UDF


torels
 Share

Recommended Posts

  • Replies 68
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

the bugs pointed out by colafrysen are now fixed :D

and I added senthor's function

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Hi again Torels.

Do you have to quit the whole iTunes application to unload the COM-Object? Is there no command to just release it?

[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
Link to comment
Share on other sites

  • 4 weeks later...

replace

Func _iTunes_Unload()
    If IsObj($iTunesApp) Then _iTunes_Quit()
    $iTunesApp = ""
EndFunc

with

Func _iTunes_Unload()
    $iTunesApp = ""
EndFunc

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

replace

Func _iTunes_Unload()
    If IsObj($iTunesApp) Then _iTunes_Quit()
    $iTunesApp = ""
EndFunc

with

Func _iTunes_Unload()
    $iTunesApp = ""
EndFunc

Does this really release the COM object, it seems as it just empties the variable :S

I am looking for a way to release the iTunes COM object so iTunes do not warn you about an application using the iTunes scripting interface...

[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
Link to comment
Share on other sites

  • 7 months later...

Hi

I am new to using com. I have been googling and trying to find a way to add a couple of things to this udf but have been unable to find out how.

Can any one tell me how to find the documentation for the iTunes com? I found a link to a page on the apple website but it asked me to login.

I have tried using oleviewer after reading the documentation for AutoIt but doesnt make much sense to me.

Or does any one know how to add in the following to the udf or get the following from iTunes:

1. Track count in the current playlist

2. Create a play list folder

3. Create a play list in a play list folder

4. Rename a play list

thanks

t92300

Link to comment
Share on other sites

  • 2 months later...

If I may suggest some additional functions?

Receive events from iTunes such as volume change, itunes quitting, etc...

Example:

OnAutoItExitRegister("_iTunes_Quit")

HotKeySet("{ESC}", "term")

Func term()
    Exit
EndFunc ;==>term

_iTunes_Start()
_iTunes_Play_Pause()
Sleep(1000)
_iTunes_Vol_Set(70)
Sleep(1000)
_iTunes_Vol_Set(30)
Sleep(1000)
_iTunes_Next()
Sleep(1000)

Add these functions into your copy of the iTunes UDF:

#region Event Handlers -- more to come...
Func iTunesEvent_OnPlayerPlayEvent()
    ConsoleWrite($iTunesApp.CurrentTrack.name & @LF)
EndFunc ;==>iTunesEvent_OnPlayerPlayEvent

Func iTunesEvent_onPlayerStopEvent()
    ConsoleWrite($iTunesApp.CurrentTrack.name & @LF)
EndFunc ;==>iTunesEvent_onPlayerStopEvent

Func iTunesEvent_OnSoundVolumeChangedEvent($newVolume)
    ConsoleWrite("Volume: " & $newVolume & @LF)
EndFunc ;==>iTunesEvent_OnSoundVolumeChangedEvent
#endregion Event Handlers

; Replace the original start function with this one:
Func _iTunes_Start()
    $iTunesApp = ObjCreate("iTunes.Application")
    ObjEvent($iTunesApp, "iTunesEvent_", "_IiTunesEvents")
    $Library_Playlist = $iTunesApp.LibraryPlaylist
    $Library_Tracks = $iTunesApp.LibraryPlaylist.Tracks
    Local $sel_Track = $iTunesApp.SelectedTracks
    Local $current_Track = $iTunesApp.CurrentTrack
    Local $Player_State = $iTunesApp.PlayerState
    $Playlist_Handle = $iTunesApp.LibrarySource.Playlists
EndFunc ;==>_iTunes_Start

Thanks goes to Richard Robertson...

Edited by jaberwocky6669
Link to comment
Share on other sites

  • 5 weeks later...

This UDF sounds great. But there isn't a way to update the song information (name, album-name, etc.), is it?

I'm looking for any tool or any way to update the song-information of every song in my whole library.

Reason is that many songs have stupid "extension" like "Club Can't Handle Me [Feat. David Guetta]/Feat. David Guetta"

I don't need that twice. The same with the album names.

I wan't to get rid of that and thought this UDF may help...

Does anybody have an idea, how to handle this #&$! "extensions"?

UTA

Edited by UTA
Link to comment
Share on other sites

I did it by myself using jscript/Wscript.

Just copy the code to a ".js" file and doubleclick it (windows) like an exe-file.

var   iTunesApp = WScript.CreateObject("iTunes.Application");
var mainLibrary = iTunesApp.LibraryPlaylist;
var tracks = mainLibrary.Tracks;
var numTracks = tracks.Count;
var i;
var currTrack;
var TrackName;
var AlbumName;
var NewTrackName;
var NewAlbumName;
var Pos ;

WScript.Echo("Library-Name  : " + mainLibrary.Name + "(" + numTracks + " Tracks)");
WScript.Echo("=====================");
WScript.Echo("");
WScript.Echo("Looking for \"]/\" ...");
WScript.Echo("");
for (i = 1; i <= numTracks; i++)
{
    currTrack = tracks.Item(i);

        TrackName = currTrack.Name.toString();
        Pos = TrackName.indexOf("]/");
        if (Pos>0){
            NewTrackName = TrackName.substring(0,Pos+1);
            WScript.Echo("Changing TRACKNAME of Track " + i + ": " + TrackName + " => " + NewTrackName);
            currTrack.Name = NewTrackName;
        }

        AlbumName = currTrack.Album.toString();
        Pos = AlbumName.indexOf("]/");
        if (Pos>0){
            NewAlbumName = AlbumName.substring(0,Pos+1);
            WScript.Echo("Changing ALBUMNAME of Track " + i + ": " + AlbumName + " => " + NewAlbumName);
            currTrack.Album = NewAlbumName;
        }
}

But I'm pretty sure, this could be handy when porting something similar to your UDF...

UTA

Link to comment
Share on other sites

  • 2 months later...

Is it me or does this UDF not work for iTunes v10?

I was trying to use the function _iTunes_Song_GetInfo($song_Name) but it wouldn't work.

Here's the script, did I do something wrong?

#include <iTunes.au3>

Global $song_Name

HotKeySet("{1}", "Pause")

While 1
    Sleep(100)
WEnd



Func Pause()
_iTunes_start()
_iTunes_Song_GetInfo($song_Name)
MsgBox(0, "Test", $song_Name[2])
EndFunc
Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

  • 1 month later...

I actually didn't test it on iTunes 10

anyway I stopped following my AutoIt projects as I used to do some time ago, I'm quite busy atm so I preferred shifting my attention on other things, hoping I will get more time to continue developing my projects and ideas

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

  • 3 months later...

I just want to make a couple comments. First, this library is helpful and saves me some time, however:

  • I'm very disappointed at how poorly this is written. Global variables with very simple (and thus easily conflicting) names? Variables without proper scope declaration? This code immediately errors out for anybody using "MustDeclareVars". Not good.
  • I'm very disappointed at all the users who have posted in this thread and haven't called the author out on this prior to me. It's also disheartening that none of you apparently use "MustDeclareVars" or Au3Check since there are tons of warnings from this library.
Link to comment
Share on other sites

Well, I was going to update the library to clean it up the Au3Check warnings and remove the global variables as much as possible. However, after taking a closer look at things I'm just going to write my own code to do what I need. The code in this library is horrible. The global variables are named even worse than I realized, there are numerous unused local variables, code is relying on global variables for arbitrary reasons and in a few cases I just don't know why the code is the way it is. I found numerous places where the code is just randomly indented differently than surrounding code. Huge warning sign to me that the quality of the product is irrelevant.

If you're using this library and it works, good for you. To anyone else I strongly suggest using the library as a base to write your own code as I honestly do not trust the code after seeing all the basic mistakes and poor design decisions.

Link to comment
Share on other sites

Well, I was going to update the library to clean it up the Au3Check warnings and remove the global variables as much as possible. However, after taking a closer look at things I'm just going to write my own code to do what I need. The code in this library is horrible. The global variables are named even worse than I realized, there are numerous unused local variables, code is relying on global variables for arbitrary reasons and in a few cases I just don't know why the code is the way it is. I found numerous places where the code is just randomly indented differently than surrounding code. Huge warning sign to me that the quality of the product is irrelevant.

If you're using this library and it works, good for you. To anyone else I strongly suggest using the library as a base to write your own code as I honestly do not trust the code after seeing all the basic mistakes and poor design decisions.

@Valik - I still haven't gotten around to checking out any of this UDF, and now I've been put off. If you are gonna put some work into it, perhaps you might share? No need for others to reinvent the wheel after all, and we'd appreciate it gladly. Unless of course you are only using bits & pieces to do what you need ... in which case however, if you just provide what you've done or just some of it to provide an example for others to go forward with, then that would be great too, as obviously the UDF needs to be re-written.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

I'm not writing a library. I only need to add and delete files from the library so I'm only writing a half dozen functions at most which are just thin wrappers around the interface (With the exception of the delete function which is more in-depth but specific to my needs).

Link to comment
Share on other sites

I'm not writing a library. I only need to add and delete files from the library so I'm only writing a half dozen functions at most which are just thin wrappers around the interface (With the exception of the delete function which is more in-depth but specific to my needs).

I also wrote an iTunes UDF for my iTunesTweet library.

All in all, the UDF is almost 2 years old, since I wrote it ages before I posted it.

It's probably full of poor code.

Link to comment
Share on other sites

  • 1 year later...
  • 8 months later...
  • 3 weeks later...

Hey Guys ... is there any chance to get the current position in a song thats currently playing?

so if I use _iTunes_Current_GetInfo() I can only get the length of the titel, but what I want to have is the exact point the player is at atm

I tried to modify something in the udf, but I can just guess what I have to call the object with since I don't know how to look up what I can ask the object .. maybe I'm just a little stupid but nevermind .. :D

$iTunesApp.CurrentTrack. <- and then? currentPosition, currPos .. it wont work :D

please help me :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...