The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Hooking up to iTunes with Windows and COM

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Hooking up to iTunes with Windows and COM Posted: Feb 16, 2008 11:21 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Hooking up to iTunes with Windows and COM
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

I was a little worried that actually working with COM (as opposed to the browsing I was doing yesterday) would be hard, but it was surprisingly easy. Here's the code I used to get a COM driver for iTunes on Windows:


getITunesCOMDriver
	"Get a driver for dealing with iTunes"
	
	| ref guid driver descs ifc |
	ref := COMRegistryInterface extTypeLibraryIDMap
		detect: [:each | 'iTunes *Type Library' match: each name]
		ifNone: [nil].
	ref ifNil: [^nil].
	descs := ref containedTypeDescriptions.
	ifc := descs
		detect: [:each | 'iTunesApp' match: each name]
		ifNone: [nil].
	ifc ifNil: [^nil].
	guid := ifc guid.
	driver := AdvancedDispatchDriver
		on:
			(IClassFactory createInstance: guid iid: External.COMConstants.IID_IDispatch context:
					External.COMConstants.CLSCTX_SERVER).
	^driver

That retrieves a driver that can receive the same kinds of messages as the iTunes AppleScript library can. In particular, this is how I then toss a Bf subscription over to iTunes (assuming it's a podcast):


doWindowsITunesSubscribeFor: aFeed
	"use COM to subscribe in iTunes"
	 
	| driver |
	driver := self getITunesCOMDriver.
	driver ifNil: [^self].
	driver SubscribeToPodcast: aFeed url.

I could use the entire available driver API with that object, but for now, all I really care about is the subscription option. All in all, it was pretty straightforward.

Technorati Tags: , ,

Read: Hooking up to iTunes with Windows and COM

Topic: ESUG 2008 Call for Submissions Previous Topic   Next Topic Topic: Something Worth Doing

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use