PDA

View Full Version : How to detect programmatically that Audio CD is inserted.


Amit Jain
03-11-2008, 04:54 AM
How to detect programmatically that Audio CD is inserted in CD Drive on macintosh?

VirtualTracy
03-11-2008, 06:16 AM
iTunes has a preference that can take care of this ...

http://img.skitch.com/20080311-nn2ds1jb96r4mr4t5xwt1tx8gy.jpg

Most audio players will do this AFAIK.

Lutin
03-11-2008, 07:23 AM
I just did that two days ago.

Send me your email by pm and I will send you the piece of code on thursday.

If you need it before, look for a code sample published by Apple. It has most of the code needed. I don't recall the name, but that should be easy to find.

Mikey-San
03-11-2008, 10:07 AM
iTunes has a preference that can take care of this ...

http://img.skitch.com/20080311-nn2ds1jb96r4mr4t5xwt1tx8gy.jpg

Most audio players will do this AFAIK.

How do you think this answers his question?

Red_Menace
03-11-2008, 07:13 PM
You didn't mention what programming you are using, but all mounted drives get an alias put in the /Volumes folder - you could periodically check the folder or use a folder action script.

Mikey-San
03-11-2008, 07:26 PM
You didn't mention what programming you are using, but all mounted drives get an alias put in the /Volumes folder - you could periodically check the folder or use a folder action script.

He'd have to install a folder action script, and have the user enable it for a folder the user can't normally see. What if his application is a GUI-less application that runs when there is no user logged into the GUI? (And as such, the Finder won't be running.) ;)

Anyway, there are ways to be notified when a device is mounted than continual polling. See:

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWorkspace_Class/Reference/Reference.html#//apple_ref/doc/uid/20000391-BCIIDEAI

As you say, however, not knowing the programming environment, we can't point anyone in the right direction.

It'd be interesting to know the higher-level goal.