|
-
May 25th, 2013, 12:31 PM
#1
Thread Starter
Member
event handling com objects - newbee
Hi
I use the COM interface of iTunes to control the program and add features. This works well. I can't get event handling to work, though.
The events that iTunes can raise are listed here: http://www.joshkunz.com/iTunesContro...nesEvents.html
I want to handle the OnPlayerPlayEvent. This is my code. The iTunes object is created properly because all regular functions work, and I use this bit of code in all my iTunes related programs. When I add the addhandler, I get an error message saying 'OnPlayerPlayEvent' is not an event of 'Object'. Can anyone see what I'm doing wrong? It is clearly listed in the interface documentation (see link)
Thank you!
Module iTunesCom
'The COM object used to interact with iTunes
Public iTunes As Object
Sub OpenITunes()
On Error Resume Next
iTunes = CreateObject("ITunes.Application")
If Err.Number <> 0 Then
MsgBox("Error: unable to open iTunes.")
End If
On Error GoTo 0
AddHandler iTunes.OnPlayerPlayEvent, AddressOf iTrackHandler
End Sub
Sub VerifyITunes()
If iTunes Is Nothing Then
OpenITunes()
End If
End Sub
Public Sub iTrackHandler(ByVal iTrack As Object)
MsgBox("A new track has started playing") 'just testing
End Sub
End Module
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
|