OSX / Xcode / Objective-C:如何检测安装的 Flash Player 版本?

发布于 2024-12-04 05:31:59 字数 309 浏览 0 评论 0原文

我需要根据 OS X 上安装的 Flash Player 版本采取不同的操作(由于 Flash bug)。有没有办法以编程方式确定版本号?

顺便说一句,我正在使用 WebKit。

编辑:

我也尝试过

NSBundle* myBundle = [NSBundle bundleWithPath: @"/Library/Internet Plug-Ins/Flash Player.plugin/Contents/Info.plist"];

,尽管路径名存在。 “myBundle”始终为零。

I need to take different action depending on the version of Flash Player installed on OS X (due to a Flash bug). Is there a way to programmatically ascertain the version number?

I am using WebKit for this, BTW.

EDIT:

I also tried

NSBundle* myBundle = [NSBundle bundleWithPath: @"/Library/Internet Plug-Ins/Flash Player.plugin/Contents/Info.plist"];

And although the pathname exists. "myBundle" is always nil.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦里兽 2024-12-11 05:31:59

您只需要使用任何能让您获得当前安装插件的 CFBundleVersion 的东西即可。类似的事情在 shell 脚本环境中有效:

/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' /Library/Internet\ Plug-Ins/Flash\ Player.plugin/Contents/Info.plist

可能有一种方法可以在系统的已安装应用程序列表中搜索与 com.macromedia.Flash Player.plugin 匹配的捆绑包 ID,并从中提取捆绑包版本系统记录也是如此。

编辑:看起来 NSWorkspace 和 Launch Services 都只是将项目映射到相关应用程序的捆绑包 ID,然后将捆绑包 ID 映射到URL 或 FSRef。因此,最终,通过这种方法,您必须获取适当的捆绑包并从那里提取版本。

可能还有一种方法可以从 Web 视图中运行的某些 JavaScript 代码获取此信息。例如,Adobe 的 SWFObject 似乎使这变得非常容易。有关详细信息,请参阅“检测 Flash Player 版本并使用 SWFObject 2 嵌入 SWF 文件”。

You just need to use anything that will let you at the CFBundleVersion of the currently installed plugin. Something like this works in a shell scripting environment:

/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' /Library/Internet\ Plug-Ins/Flash\ Player.plugin/Contents/Info.plist

There might be a way to search the system's list of installed applications for a bundle ID matching com.macromedia.Flash Player.plugin and pull out the bundle version from the system record, as well.

EDIT: It looks like both NSWorkspace and Launch Services just map items to bundle IDs of relevant apps, and then will map a bundle ID to a URL or FSRef. So ultimately, with this approach, you have to grab the appropriate bundle and pull out the version from there.

There's likely also a way to get this information from some JavaScript code running within the webview. Adobe's SWFObject seems to make this quite easy, for example. For more, see "Detecting Flash Player versions and embedding SWF files with SWFObject 2".

简单 2024-12-11 05:31:59

只需省略 Contents/Info.plist 部分即可;您需要获取捆绑包,而不是其 Info.plist:

NSBundle* flashBundle = [NSBundle bundleWithPath: @"/Library/Internet Plug-Ins/Flash Player.plugin"];
NSString flashVersion = flashBundle.infoDictionary[(id)kCFBundleVersionKey];

请记住,如果没有安装 Flash Player,请盖上外壳。

Just leave off the Contents/Info.plist part; you need to get the bundle, not its Info.plist:

NSBundle* flashBundle = [NSBundle bundleWithPath: @"/Library/Internet Plug-Ins/Flash Player.plugin"];
NSString flashVersion = flashBundle.infoDictionary[(id)kCFBundleVersionKey];

Remember to cover the case when there is no Flash Player installed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文