midi api java_Java声音api – 扫描MIDI设备

MidiSystem.getMidiDeviceInfo()获取完整的提供程序列表,并从每个提供程序中提取设备的信息.

MIDIs提供程序列表从JDK底层类别com.sun.media.sound.JDK13Services中恢复,通过静态方法getProviders()

public static synchronized List getProviders(Class serviceClass)

Obtains a List containing installed

instances of the providers for the

requested service. The List of

providers is cached for the period of

time given by cachingPeriod . During

this period, the same List instance is

returned for the same type of

provider. After this period, a new

instance is constructed and returned.

The returned List is immutable.

所以,这个类似乎在你的缓存中保存了你的提供者列表,一段时间后会被重新加载.您可以使用setCachingPeriod(int seconds)方法将此时段设置为自定义值.只要我知道,默认缓存期间设置为60秒.

例如,要每秒刷新此缓存,您可以将此行添加到您的代码中:

com.sun.media.sound.JDK13Services.setCachingPeriod(1);

请注意,这个解决方案使用了Sun Propietary类,所以它不能100%便携.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值