It does work with other .wav files, consider a bit smaller IStrategy example which plays alert every 10 seconds:
package jforex.codebase.test;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
import javax.sound.sampled.*;
import com.dukascopy.api.*;
@RequiresFullAccess
public class AlerterMini implements IStrategy {
private IContext context;
private Instrument instrument = Instrument.EURUSD;
private Period period = Period.TEN_SECS;
@Configurable("Alarm file 1")
public File alarmFile1 = new File("C:\\temp\\duck.wav");
@Configurable("Alarm file 2")
public File alarmFile2 = new File("C:\\temp\\bird.wav");
private SimpleDateFormat sdf;
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
if (!this.period.equals(period) || !this.instrument.equals(instrument))
return;
print("play: " + sdf.format(bidBar.getTime()));
playSound(alarmFile1);
}
public void onStart(IContext context) throws JFException {
this.context = context;
String DATE_FORMAT_NOW = "HH:mm:ss SSS"; //yyyy-MM-dd
sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
print("start");
playSound(alarmFile2);
}
public void onStop() throws JFException {}
public void onTick(Instrument instrument, ITick tick) throws JFException { }
private void playSound(File wavFile) throws JFException {
try {
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(wavFile);
AudioFormat af = audioInputStream.getFormat();
int nSize = (int) (af.getFrameSize() * audioInputStream.getFrameLength());
byte[] audio = new byte[nSize];
DataLine.Info info = new DataLine.Info(Clip.class, af, nSize);
audioInputStream.read(audio, 0, nSize);
Clip clip = (Clip) AudioSystem.getLine(info);
clip.open(af, audio, 0, nSize);
clip.start();
} catch (Exception e) {
e.printStackTrace();
print("errror on play: " + e.getMessage());
//throw new JFException(e);
}
}
private void print(Object o){
context.getConsole().getOut().println(o);
}
}
Find the example .wav files in attachments