Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

how to use sound in a jforex strategy
 Post subject: how to use sound in a jforex strategy Post rating: 0   New post Posted: Mon 20 Oct, 2014, 09:39 
User avatar

User rating: 1
Joined: Fri 22 Mar, 2013, 12:09
Posts: 9
Location: Italy, Florence
hi

i build the attached strategy in java code with jforex desktop, the
strategy have to play a sound (pin.wav) when it's found a pin on timeframe
15min/30min/1h/4h on major and minor pairs
For this implementation i followed this example:
https://www.dukascopy.com/wiki/#Create_Alert

when i run it on jforex desktop, i get the error message:
access denied File permission on pin.wav (see the attached image
errosound.png)
i run the strategy in local mode

why? i have full permission on that file

i use windows 7 as operation system, and i'm administrator of my pc

i use this code to play the sound:

public File wavFile = new File("C:\\Temp\\pin.wav");


private void playSound(File wavFile) {

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();
console.getOut().println("error on play: " + e.getMessage());
//throw new JFException(e);
}
}

P.S.
ok i writed the post
i need to use jforex deskton and no visual jforex (vjf) because i want to run my stategy on multi pairs and multi timeframe and i can't do that with vjf

best regards
--
Andrea
Image


Attachments:
errsound.png [10.66 KiB]
Downloaded 216 times
PinSeeker_v1.java [25.45 KiB]
Downloaded 91 times
pin.wav [272.08 KiB]
Downloaded 69 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: how to use sound in a jforex strategy Post rating: 0   New post Posted: Mon 20 Oct, 2014, 10:09 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You need to add @RequiresFullAccess annotation to your strategy if you want to access files outside your IContext.getFilesDir() directory.


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com