Play external Sound File

Back to topics list To post a new topic, please log in or register
avatar
315
sunshineh 2016.09.06 16:23
 

Hi,

the function PlaySound(...) plays the soundfile that must be located in terminal_directory\Sounds or its sub-directory.

How can I play a sound file from the C:\Windows\Media path?


avatar
12985
WHRoeder 2016.09.06 16:48 #
 
  1. You can't from mql4. You'd have to shell the file
  2. Disk space is cheap, just copy the file. Or make a hard link to it: fsutil hardlink create soundsDirectory existingFile
avatar
1200
FMIC 2016.09.06 16:48 #
 

I can think of two possibilities:

  • Either, use a DLL call to the WinAPI for that
  • or add a Junction Point to the "terminal_directory\Sounds" to point to other media folders.

avatar
1318
jjc 2016.09.06 17:09 #
 
sunshineh:

Hi,

the function PlaySound(...) plays the soundfile that must be located in terminal_directory\Sounds or its sub-directory.

How can I play a sound file from the C:\Windows\Media path?

An adaptation of https://forum.mql4.com/60173#894658:

#import "winmm.dll"
   int PlaySoundW(string, int, int);
#import

void OnStart()
{
   PlaySoundW("c:\\windows\\media\\chimes.wav", 0, 1 /* SND_ASYNC */);
}

 

avatar
315
sunshineh 2016.09.06 18:38 #
 

Great!!!

Thank you very much!

Back to topics list  

To add comments, please log in or register