Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSWorkSpace Eject CD

NSWorkSpace Eject CD
Thread Tools
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
May 7, 2002, 05:19 PM
 
I'm trying to do
[[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath:@"/volumes/Audio CD"]

But it's failing so I think I need the /dev/something path of the CD-Rom drive. I don't know what this is, does anybody else?
     
Junior Member
Join Date: Apr 2000
Location: San Francisco, CA
Status: Offline
Reply With Quote
May 8, 2002, 02:21 AM
 
Originally posted by davecom:
<STRONG>I'm trying to do
[[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath:@"/volumes/Audio CD"]

But it's failing so I think I need the /dev/something path of the CD-Rom drive. I don't know what this is, does anybody else?</STRONG>
This is incredibly easy to do in Carbon. Iterate over each mounted volume, check to see if it is ejectable CD, if it is, umount the volume. More Files X gives you easy to use wrappers around the low-level carbon calls to make this happen.

Michael Kamprath
--
Michael F. Kamprath
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
May 8, 2002, 02:52 AM
 
Originally posted by davecom:
<STRONG>I'm trying to do
[[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath:@"/volumes/Audio CD"]

But it's failing so I think I need the /dev/something path of the CD-Rom drive. I don't know what this is, does anybody else?</STRONG>
that method has always worked for me. of course, this only works if the cd is not in use by any application.

when this fails -- is the cd in use by itunes, for example?

btw, i don't know whether the line you posted was complete or not, you know that you get a YES or NO in return for success or failure, right?

(seems like a bug to me: even if you get a "NO" in return, the array returned by nsworkspace's mountedRemovableMedia does *not* contain that volume anymore, had to write some ugly workarounds)

edit: is that copy and paste from your code? "Volumes" has a capital "v".

[ 05-08-2002: Message edited by: seb2 ]
     
davecom  (op)
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
May 8, 2002, 01:33 PM
 
I'm not sure I'm understanding. You're saying the method doesn't work? Here's my code:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier> - (IBAction)Ejectid)sender
{
if (discExists)
{
if ([[NSWorkspace sharedWorkspace] unmountAndEjectDeviceAtPath:<font color = orange>@"/Volumes/Audio CD"</font>])
{
discExists = NO;
[someMovie release];
[Table reloadData];
[mainWindow setTitle:<font color = orange>@"Please Insert a Compact Disc"</font>];
}
else
NSRunAlertPanel(<font color = orange>@"Unable to Eject<font color = red>"</font>, <font color = orange>@"</font>The Audio CD was not ejected because an error occured."</font>, nil, nil, nil);
}
}
</font>[/code]

Also, what is this "More Files X"?
     
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
May 8, 2002, 02:53 PM
 
Originally posted by seb2:
<STRONG>

that method has always worked for me. of course, this only works if the cd is not in use by any application.</STRONG>
For me, it works for CD's, but it doesn't work for anything that's not marked as ejectable, and unfortunately guess what? Servers are not marked as ejectable. So it's necessary to use the Carbon calls, although I wouldn't call it "incredibly easy," or even bug-free.

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
davecom  (op)
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
May 8, 2002, 03:12 PM
 
Originally posted by CharlesS:
<STRONG>

For me, it works for CD's, but it doesn't work for anything that's not marked as ejectable, and unfortunately guess what? Servers are not marked as ejectable. So it's necessary to use the Carbon calls, although I wouldn't call it "incredibly easy," or even bug-free.</STRONG>
Perhaps I need to release the NSMovie object that is attached to a movie on the CD before I eject it?
     
Dedicated MacNNer
Join Date: Feb 2002
Status: Offline
Reply With Quote
May 9, 2002, 06:58 PM
 
Originally posted by davecom:
<STRONG>what is this "More Files X"?</STRONG>
Sample Code @ Apple
     
davecom  (op)
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
May 9, 2002, 07:47 PM
 
Originally posted by davecom:
<STRONG>

Perhaps I need to release the NSMovie object that is attached to a movie on the CD before I eject it?</STRONG>
Yes, that was the problem, problem solved. Thanks everyone for the help none the less.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:55 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2