简体   繁体   English

OSX-Mounting DVD 不以编程方式启动用户指定的应用程序

[英]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 .我已经注册了回调函数DADiskAppearedCallbackDADiskDisappearCallback

For the usb drives all seems to work perfectly but for the CD/DVD I am facing the problem.对于 USB 驱动器,似乎一切正常,但对于 CD/DVD,我遇到了问题。

After CD/DVD get loaded I have unmount ( DADiskUnmount() ) the drive using BSDName of the disk.加载 CD/DVD 后,我使用磁盘的 BSDName 卸载( DADiskUnmount() )驱动器。 Then after some verification of the disk I do mount ( DADiskMount() ) the disk again using BSDName.然后在对磁盘进行一些验证后,我再次使用 BSDName 挂载( DADiskMount() )磁盘。

When I mount CD/DVD again, the default application set in the当我再次挂载 CD/DVD 时,默认应用程序设置在

system preference->Hardware->Cds & DVSs系统偏好->硬件->Cds & DVSs

is not getting launch.没有启动。

For eg.例如。 For Video DVD - Open DVD Player.对于视频 DVD - 打开 DVD 播放器。 Here DVD player should get launched.这里应该启动 DVD 播放器。

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.我仍在寻找遇到的解决方案,“SystemUIServer”管理应该在插入 CD/DVD 时安装的应用程序。 Can I able to trigger that action on the CD/DVD mount?我可以在 CD/DVD 安装上触发该操作吗? Or Is this proper way to manually launch user provided application on CD/DVD mount?或者这是在 CD/DVD 安装上手动启动用户提供的应用程序的正确方法吗?

You might try tickling it with NSWorkSpace你可以尝试用 NSWorkSpace 挠痒痒

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWorkspace_Class/index.html#//apple_ref/c/data/NSWorkspaceDidMountNotification 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首先创建一个 NSWorkspaceDidMountNotification 类型的 NSNotification

Be sure to set the userInfo dictionary KVPs as appropriate.确保适当地设置 userInfo 字典 KVP。 (In the NSWorkspace docs) (在 NSWorkspace 文档中)

Finally, post the notification to the workspace Notification Center [NSWorkspace notificationCenter]最后,将通知发布到工作区通知中心【NSWorkspace通知中心】

I suspect that might be the trick.我怀疑这可能是诀窍。

EDIT This doesn't seem to do the trick编辑这似乎不起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM