Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX-Mounting DVD programmatically does not launch user specified application

I have used disk-arbitration framework for managing various drives and disks.

I have registered callback functions DADiskAppearedCallback and DADiskDisappearCallback.

For the usb drives all seems to work perfectly but for the CD/DVD I am facing the problem.

After CD/DVD get loaded I have unmount (DADiskUnmount()) the drive using BSDName of the disk. Then after some verification of the disk I do mount (DADiskMount()) the disk again using BSDName.

When I mount CD/DVD again, the default application set in the

system preference->Hardware->Cds & DVSs

is not getting launch.

For eg. For Video DVD - Open DVD Player. Here DVD player should get launched.

How do I overcome this problem?

I am still searching for the solution came across, "SystemUIServer" manages the application that should mount on insertion of CD/DVD. Can I able to trigger that action on the CD/DVD mount? Or Is this proper way to manually launch user provided application on CD/DVD mount?

like image 683
Harshal Chaudhari Avatar asked Jan 07 '15 07:01

Harshal Chaudhari


1 Answers

You might try tickling it with NSWorkSpace

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWorkspace_Class/index.html#//apple_ref/c/data/NSWorkspaceDidMountNotification

First create an NSNotification of type NSWorkspaceDidMountNotification

Be sure to set the userInfo dictionary KVPs as appropriate. (In the NSWorkspace docs)

Finally, post the notification to the workspace Notification Center [NSWorkspace notificationCenter]

I suspect that might be the trick.

EDIT This doesn't seem to do the trick

like image 54
uchuugaka Avatar answered Oct 23 '22 06:10

uchuugaka