Promotic

PlaySound - method of the Pm object

Description:
Playing the *.wav sound file by the sound server of the PROMOTIC system.
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:
Empty PlaySound(String 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; - WAV sound file.
Once the file playback starts it has to be played up to the end, and therefore it is recommended to use shorter files with repeat enabled, better than long playtime files.
repeat:nn; - The number of sound repeat (1 = default, -1 = unlimited).
stop:nn; - It 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.
If some of the removed sound requests is currently being played then the playback is terminated immediately.
Other options (file and repeat) are ignored in this case.
Note:
Caution:
- The method is asynchronous, it means that the impulse for sound playback is generated, but the system does not wait for actual execution of such command (and 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.


This method is also functional in Web panels. In such case this 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 Web panels).
- The InternetExplorer browser (less than 11) does not support playback of wav files (Chrome, Firefox, Edge support this format).
This method on the 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, then it is necessary to create the sond files in both formats and play one file in local application and the other file on the Web.
See Example3


The old syntax of this method returned 0 (success) or 1 (error) and had three parameters:
sFile (String) - The file name with the path.
If the value je an empty string, then 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 will not 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 of the sound file (queueing into the sound server)
JavaScriptVBScriptSelect and copy to clipboard

Pm.PlaySound("file:#pmres:Sound/hoot01.wav;");
Example2:
Cancelling all requests in the sound server queue, created by the PlaySound method.
JavaScriptVBScriptSelect and copy to clipboard

Pm.PlaySound("stop:1;");
Example3:
Calling the method in the panel that is functional in both local application and in the Web browser (Chrome, Firefox, Edge, InternetExplorer ...).
The designer has to convert the wav file into mp3 format and save it into the file folder #appres:.
JavaScriptSelect and copy to clipboard

if (1 == pMe.Root.ClientType)
{
Pm.PlaySound("file:#pmres:Sound/hoot01.wav;");
}
else
{
Pm.PlaySound("file:#appres:hoot01.mp3;");
}

History:
Pm9.00.26: Parameters repeat and stop enabled for the Web.
Pm9.00.03: Fixed bug: stop:1 terminates sound playback (the sound does not play to the end as it did before)
Pm8.00.06: Fixed bug: Available for Web panels.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
Navigation:
 
- Pm
 
- Abs
- Cos
- E
- Exp
- LN2
- PI
- PlaySound
 
 
- Pow
- Sin
- Tan
© MICROSYS, spol. s r.o.