use of jmri.AudioManager in project JMRI by JMRI.
the class AbstractAudioSource method setAssignedBuffer.
@Override
public void setAssignedBuffer(String bufferSystemName) {
if (!queued) {
AudioManager am = InstanceManager.getDefault(jmri.AudioManager.class);
Audio a = am.getBySystemName(bufferSystemName);
if (a.getSubType() == Audio.BUFFER) {
setAssignedBuffer((AudioBuffer) a);
} else {
log.warn("Attempt to assign incorrect object type to buffer - AudioBuffer expected.");
this.buffer = null;
this.bound = false;
}
} else {
log.error("Attempted to assign buffer " + bufferSystemName + " to Queued Source " + this.getSystemName());
}
}
use of jmri.AudioManager in project JMRI by JMRI.
the class SoundBite method init.
public final boolean init(VSDFile vf, BufferMode mode) {
AudioManager am = jmri.InstanceManager.getDefault(jmri.AudioManager.class);
if (!initialized) {
try {
sound_src = (AudioSource) am.provideAudio(SrcSysNamePrefix + system_name);
sound_src.setUserName(BufUserNamePrefix + user_name);
setLooped(false);
if (mode == BufferMode.BOUND_MODE) {
sound_buf = (AudioBuffer) am.provideAudio(BufSysNamePrefix + system_name);
sound_buf.setUserName(BufUserNamePrefix + user_name);
if (vf == null) {
log.debug("VSD file is null! Filename: {}", filename);
// Path must be provided by caller.
sound_buf.setURL(filename);
} else {
java.io.InputStream ins = vf.getInputStream(filename);
if (ins != null) {
sound_buf.setInputStream(ins);
} else {
return (false);
}
}
sound_src.setAssignedBuffer(sound_buf);
setLength();
}
} catch (AudioException | IllegalArgumentException ex) {
log.warn("Problem creating SoundBite: " + ex);
}
}
return (true);
}
Aggregations