Add external Sound to EA

 
Hello,

I'm starting to program EAs recently and I have a question.

My question is about reproducing sounds, currently the MQL4 souns folder is pretty limited. I have seen in documentation that we can add other types of wav sounds as long as we copy and paste the new sound in the meta trader folder sound.

Is there any way to add new sounds without having to paste them in the meta trader sounds folder? I would like to do this for when i start to selling the EAs and it is not necessary for the client to copy and paste the new sounds in the meta trader folder .


Sorry my english,


Thanks .

 
Ds Trade: I'm starting to program EAs recently and I have a question. My question is about reproducing sounds, currently the MQL4 souns folder is pretty limited. I have seen in documentation that we can add other types of wav sounds as long as we copy and paste the new sound in the meta trader folder sound. Is there any way to add new sounds without having to paste them in the meta trader sounds folder? I would like to do this for when i start to selling the EAs and it is not necessary for the client to copy and paste the new sounds in the meta trader folder .

MQL4 Resources: Including resources to executable files during compilation of mql4 programs

Resources - MQL4 programs - MQL4 Reference
Resources - MQL4 programs - MQL4 Reference
  • docs.mql4.com
//| Calls standard OrderSend() and plays a sound                     | The example shows how to play sounds from files 'Ok.wav' and 'timeout.wav', which are included into the standard terminal package. These files are located in the folder is a folder, from which the MetaTrader 4 Client Terminal is started. The location of the terminal...
 

Thank you very much Fernando,


I was able to save the audio files in #resource. How can I call this resource audios to play? Using PlaySound ()? Can you give me an example, thank you.

 
Ds Trade: Thank you very much Fernando, I was able to save the audio files in #resource. How can I call this resource audios to play? Using PlaySound ()? Can you give me an example, thank you.

It is right there in the documentation examples:

Use of Resources

Resource name

After a resource is declared using the #resource directive, it can be used in any part of a program. The name of the resource is its path without a backslash at the beginning of the line, which sets the path to the resource. To use your own resource in the code, the special sign "::" should be added before the resource name.

Examples:

//--- examples of resource specification and their names in comments
#resource "\\Images\\euro.bmp"          // resource name - Images\euro.bmp
#resource "picture.bmp"                 // resource name - picture.bmp
#resource "Resource\\map.bmp"           // resource name - Resource\map.bmp
#resource "\\Files\\Pictures\\good.bmp" // resource name - Files\Pictures\good.bmp
#resource "\\Files\\Demo.wav";          // resource name - Files\Demo.wav"
#resource "\\Sounds\\thrill.wav";       // resource name - Sounds\thrill.wav"
...                                  
 
//--- utilization of resources
ObjectSetString(0,bitmap_name,OBJPROP_BMPFILE,0,"::Images\\euro.bmp");
...
ObjectSetString(0,my_bitmap,OBJPROP_BMPFILE,0,"::picture.bmp");
...
set=ObjectSetString(0,bitmap_label,OBJPROP_BMPFILE,1,"::Files\\Pictures\\good.bmp");
...
PlaySound("::Files\\Demo.wav");
...
PlaySound("::Sounds\\thrill.wav");


 
Fernando Carreiro:

It is right there in the documentation examples:

Use of Resources

Resource name

After a resource is declared using the #resource directive, it can be used in any part of a program. The name of the resource is its path without a backslash at the beginning of the line, which sets the path to the resource. To use your own resource in the code, the special sign "::" should be added before the resource name.

Examples:


Thanks woked using "::filename.wav"