Jump to content

iTunes UDF


torels
 Share

Recommended Posts

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 :)

My has this built in _iTunes_PlayerPos(), you call $iTunesApp.PlayerPosition
Link to comment
Share on other sites

  • Replies 68
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

thanks James! :)

I added this to the udf in this thread and it worked. just didn't knew where to get the command I can ask the object.

Where do you get this, how can you figure out that it is called .PlayerPosition ?

but what ever .. it's working :D Thanks for your reply :)

€: and there's something else I would like to ask .. is there any chance to unload the itunes object without quitting itunes?

Edited by Leo1906
Link to comment
Share on other sites

Where do you get this, how can you figure out that it is called .PlayerPosition ?

but what ever .. it's working :D Thanks for your reply :)

€: and there's something else I would like to ask .. is there any chance to unload the itunes object without quitting itunes?

The documentation :) I made great use of it when I was writing iTunesTweet. I've uploaded it to Dropbox.

Good question. This was the bane of many problems for me. If you take a look at the bottom of my UDF you'll see these functions:

; Sets the $iCOMEvnt to 1 if COM is disabled
Func _iTunesCOM_onCOMCallsDisabledEvent($reason)
    $iCOMEvnt = 1
    ConsoleWrite("!>COM Disabled... " & _iTunesRes_Disabled($reason) & @CRLF)
    Return 0
EndFunc   ;==>_iTunesCOM_onCOMCallsDisabledEvent

; Sets the $iCOMEvnt to 0 if COM is enabled
Func _iTunesCOM_onCOMCallsEnabledEvent()
    $iCOMEvnt = 0
    ConsoleWrite("+>COM Enabled..." & @CRLF)
    Return 1
EndFunc   ;==>_iTunesCOM_onCOMCallsEnabledEvent

; Quits the iTunes COM interface
Func _iTunesCOM_OnQuittingEvent()
    _iTunes_Quit()
    ProcessWait("itunes.exe") ; Wait for the process to come back
    _iTunes_Start()
EndFunc   ;==>_iTunesCOM_OnQuittingEvent

; If the database changes (renamed/deleted/moved) whilst playing just ignore it
Func _iTunesCOM_OnDatabaseChangedEvent()
    Return 1
EndFunc   ;==>_iTunesCOM_OnDatabaseChangedEvent

Func _iTunesCOM_OnPlayerPlayingTrackChanged()
    _iTunes_Quit() ; Close the iTunes COM handle
    _iTunes_Start() ; Then re-open it to get all of the data again
    Return 0
EndFunc   ;==>_iTunesCOM_OnPlayerPlayingTrackChanged

; What happens when iTunes wants to close
Func _iTunesCOM_OnAboutToPromptUserToQuitEvent()
    ConsoleWrite("->iTunes says bye bye!" & @CRLF)
    _iTunes_Quit()
EndFunc   ;==>_iTunesCOM_OnAboutToPromptUserToQuitEvent

; Returns the value why the COM is disabled
Func _iTunesRes_Disabled($iReason)
    Switch $iReason
        Case 0
            Return "COM interface is being disabled: for some other reason."
        Case 1
            Return "COM interface is being disabled: a modal dialog is being displayed."
        Case 2
            Return "COM interface is being disabled: iTunes is quitting."
        Case Else
            Return "COM interface is being disabled: only iTunes knows why."
    EndSwitch
EndFunc   ;==>_iTunesRes_Disabled

When iTunes quit and my program was running, it'd crash. This is how I got about that :)

Link to comment
Share on other sites

  • 1 month later...

Hey torels, it's been a while since you wrote Your script is awesome. I am just starting with AutoIt. I am looking for a way to control Airplay speakers, to activate and deactivate them by name. Do you know a way I can do that? Thank you and congrats.

Link to comment
Share on other sites

  • 10 months later...
  • 1 year later...

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...