Promotic
WikipediaLinkedInYoutubeTwitterFacebook

PlaySound - method of object Pm

Description:
Playing the *.wav sound file by the Promotic sound server. The system is able to play one sound at a time. Therefore the sound requests are queued into the sound server. The order of the sound requests is based on priority and time of origin.
Syntax:
PlaySound(sSound As String)
Calling:
Pm.PlaySound sSound
Parameters:
sSound(String) The sound parameters define the way the sound is played. For example: "file:#pmres:Sound/hoot01.wav;repeat:5;".
file:xx; - Sound file. It is recommended to use the PROMOTIC path syntax - see PROMOTIC path to files and folders.

There are some *.wav files located in the Promotic folder ("/Pm/Resource/Sound") that can be used. The link to these files is for example #pmres:Sound/alarm01.wav. The designer can create personal files and place them into the application source folder (see the configurator "Paths to system folders"). For example of the filelink: #appres:MySound1.wav.

repeat:nn; - Sound repeat number (1 = default, -1 = unlimited).
stop:nn; - Allows to remove the sound requests created by the PlaySound method from the sound queue.
0 (default) - Does nothing.
1 - Removes the sound requests created by the PlaySound method from the sound queue. Other options (file and repeat) are ignored in such case.
Note:
Caution:
- The method is asynchronous, i.e. the impulse for sound playback is generated, but the system does not wait for actual execution of such command (therefore the method does not return the completion report).
- For playing the sound file it is necessary that the system has a functional sound card installed.
 
The method can also be called in the graphic item events for Web Panels. In such case the method has following limitations:
- Each sound playback in the WEB panel will terminate the playback of previous sound (the sound server is not present in the web panels).
- The InternetExplorer browser does not support playback of wav files (Chrome, Firefox support this format). This method on WEB supports playback of mp3 files (this format is supported by all browsers), but this format is not supported by local application. Therefore if it is required to have this method working both in InternetExplorer and in local application, it is necessary to create the sond files in both formats and play one file in local application and the other file on WEB. See Example3
 
The old syntax of this method returned 0 (success) or 1 (error) and had three parameters:
sFile (String) - Name of the sound file (including the path). If the value is an empty string, playing the just played sound file is stopped.
nPriority (Long) - Priority (reserved, set to 0).
nFlags (Long) - Flags that identify the way how to play the sound (can be summed).
1 - (NoStop) - The flag causes that the just played sound file won't be interrupted and the method will stop immediately with the error flag (returns 1) (it can be used for testing if there is or isn't played up the sound file).
2 - (Loop) - The flag makes the file playback continue in endless loop. The playback is terminated by opening another sound file.
Example1:
Playback (queueing into the sound server) of the sound file
Pm.PlaySound "file:#pmres:Sound/hoot01.wav;"
Example2:
Cancelling all requests in the sound server queue, created by the PlaySound method.
Pm.PlaySound "stop:1;"
Example3:
Calling the method in panel that is functional in both local application and on the WEB in InternetExplorer (in Chrome, Firefox ...). The application designer has to convert the wav file into mp3 format and save it into the file folder #appres:. (Example for JavaScript language)
  Pm.PlaySound "file:#pmres:Sound/hoot01.wav;"
else
  Pm.PlaySound "file:#appres:Sound/hoot01.mp3;"
Navigation:
 
- Pm
 
- Abs
- Cos
- E
- Exp
- LN2
- PI
- PlaySound
 
 
- Pow
- Sin
- Tan
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice