 |
 |
NSWorkSpace Eject CD
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Location: New York
Status:
Offline
|
|
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
|
|
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
|
|
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 ]
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Location: New York
Status:
Offline
|
|
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)Eject  id)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
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Location: New York
Status:
Offline
|
|
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
|
|
Originally posted by davecom:
<STRONG>what is this "More Files X"?</STRONG>
Sample Code @ Apple
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Location: New York
Status:
Offline
|
|
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.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|