简体   繁体   English

运行时的Java Carbon Component警告 - OS X.

[英]Java Carbon Component warning on runtime - OS X

I recently learnt how to add sound into a small snake game i am creating. 我最近学会了如何将声音添加到我正在创建的小蛇游戏中。 The sound plays when the snake eats the apple. 当蛇吃苹果时声音会播放。 The problem i have is every time the snake eats an apple i get this warning in the cosole (but the program continues to run): 我遇到的问题是每次蛇吃苹果我都会在cosole中得到这个警告(但程序继续运行):

015-10-13 10:00:16.922 java[39731:970632] 10:00:16.922 WARNING: 140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. 015-10-13 10:00:16.922 java [39731:970632] 10:00:16.922警告:140:此应用程序或其使用的库正在使用不推荐使用的Carbon Component Manager来托管Audio Units。 Support for this will be removed in a future release. 将来的版本中将删除对此的支持。 Also, this makes the host incompatible with version 3 audio units. 此外,这使主机与版本3音频单元不兼容。 Please transition to the API's in AudioComponent.h . 请转到AudioComponent.h的API。

What does this mean, and what would i need to do to fix this error? 这是什么意思,我需要做些什么才能解决这个错误?

Here is my method to play the sound: 这是播放声音的方法

 private static void playSound(File Sound){

    try{
        Clip clip = AudioSystem.getClip();
        clip.open(AudioSystem.getAudioInputStream(Sound));
        clip.start();

        Thread.sleep(clip.getMicrosecondLength()/1000);

    }catch(Exception e){

    }

}

TL;DR: TL; DR:

This is a console warning intended for the developers in charge of your sound handler, which in this case looks like AudioSystem . 这是一个控制台警告,供负责声音处理程序的开发人员使用,在本例中看起来像AudioSystem Your program should work, but it'll keep throwing these warnings. 你的程序应该工作,但它会继续抛出这些警告。 Are you using an older version of Java? 您使用的是旧版Java吗? That might explain the issue. 这可能解释了这个问题。

Longform: 长表:

I came across this question because I got the same warning (with a different time and process stamp) working with SimpleCV in Python. 我遇到了这个问题,因为我在Python中使用SimpleCV获得了相同的警告(使用不同的时间和流程标记)。 I did a little digging and I think I can at least elaborate on the issue, if not solve it. 我做了一点挖掘,我想我至少可以解决这个问题,如果不解决的话。

First, this is an Apple-specific issue. 首先,这是Apple特有的问题。 The warning we're seeing is actually a console log note, which you can see if you open up your Console and look for the timestamp. 我们看到的警告实际上是一个控制台日志记录,如果您打开控制台并查找时间戳,则可以看到该记录。 The Carbon Component Manager is a deprecated way that Macs handles sound, and is being phased out for a newer way that uses AudioComponent.h . Carbon Component Manager是Macs处理声音的一种不推荐使用的方式,并且正在逐步淘汰使用AudioComponent.h的新方法。 It looks like AudioSystem is still going about its business the older way. 看起来AudioSystem仍然以较旧的方式开展业务。 This note is a signal to the developers that they need to update AudioSystem to interface with the new API. 本说明向开发人员发出信号,表示他们需要更新AudioSystem以与新API连接。 It's possible this has already been resolved in newer Java versions. 这可能已在较新的Java版本中得到解决。 Your program should work fine if you just ignore it, but you could try using a newer Java version to see if that helps. 如果您忽略它,您的程序应该可以正常工作,但您可以尝试使用较新的Java版本来查看是否有帮助。

I'd recommend editing your question to include your system specs and Java version. 我建议您编辑问题以包含系统规格和Java版本。

More info on Carbon Core Deprecation: 有关Carbon Core Deprecation的更多信息:

https://developer.apple.com/library/mac/releasenotes/General/CarbonCoreDeprecations/ https://developer.apple.com/library/mac/releasenotes/General/CarbonCoreDeprecations/

In case anyone else runs into this from SimpleCV/Python, and for completeness: 如果其他人从SimpleCV / Python遇到此问题,并且为了完整性:

I'm running OSX El Capitan on a Macbook Pro (Late 2011), using Python 3.5 and SimpleCV 1.3. 我使用Python 3.5和SimpleCV 1.3在Macbook Pro(2011年末)上运行OSX El Capitan。 My console warning (I'm guessing) stems from the shutter sound that is played when Camera() is used to take a picture in SimpleCV. 我的控制台警告(我猜是)源于使用Camera()在SimpleCV中拍照时播放的快门声。

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

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