Contribute  :  Calendar  :  Advanced Search  :  Site Statistics  :  Directory  :  Files to download  :  Links for developers  :  Privacy policy  :  Web Resources  :  Polls  
    MacOSX Guru Site Information, tips and tricks, FAQ for Mac OS X developers    
 Welcome to MacOSX Guru Site
 Friday, December 15 2017 @ 09:30 PM UTC

How to open the CD tray programmatically ?

   
Objective-CHow can I open the CD Tray with cocoa / objective-c. I would like to recreate the functionality of the iTunes eject button.

First don't forget: there is no *the* CD tray. You may have several CD/DVD drives, some have trays, some not (slot loading), etc.

You need to link to the disc recording framework:

#import <DiscRecording/DRDevice.h>
...
NSArray	*devices = [DRDevice devices]	;
NSEnumerator *aEnum = [devices objectEnumerator];	
DRDevice *aDevice	;
	
	while ((aDevice = [aEnum nextObject]) != nil) {
		if ([[[aDevice info] objectForKey:DRDeviceLoadingMechanismCanOpenKey] boolValue]) {
			// there are also DRDeviceLoadingMechanismCanInjectKey and DRDeviceLoadingMechanismCanEjectKey
			// the device supports openTray and closeTray
			[aDevice openTray] ;

			...


			[aDevice closeTray] ;
 		}
	}
 

What's Related

Story Options

How to open the CD tray programmatically ? | 0 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
 Copyright © 2017 MacOSX Guru Site
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.05 seconds