<< Click to Display Table of Contents >> Navigation: 3. Script Language > Multimedia Commands > Multimedia Commands |
MiniRobotLanguage (MRL)
MPB. Command
Music Play Background
Intention
The MPB. command acts as a "Background Audio Player". It is part of a set of commands that includes MPC. - Music Player Commands. These commands enable you to play music or any audio in the background. For instance, you can use it to play music during an automated installation process.
However, its uses aren't limited to music playback. For instance, you can use it to play a "police siren" sound during alarm conditions.
To utilize the MPB., you need to feed it an audio file. As it operates in the background, a separate command is required to check if it's ready to play the audio. If we neglect to do so, we won't hear any audio because when the script concludes, MPB. also terminates any ongoing playback
Simple Example:
' Start the PLayback, here we assume that the song is located
' in ?path\, that is where the scriptfile is.
MPB.MySong.mp3
' Now we wait until the sound was played
WRS.
' We drop the result
DRS.
' We end the script.
ENR.
MPB. can also accept a list of Audio Files (Play-List).
The Songs must be separated using a ">" Sign. Example:
MPB.MySong.mp3>MySong2.mp3>MySong3.mp3
Of course this makes more sense using a variable:
$$PLI=MySong.mp3>MySong2.mp3>MySong3.mp3
MPA.$$PLI
You can add a third parameter to get the "Ticket-Number" of the background task.
Using the "Ticket Number" you can control the background task.
More details on how to work with a "Ticket number" and background tasks, see:
"Ticket Numbers" and Background Tasks
Using the ticket number and the MPC. - command, you can influence the behavior of the playing song.
' Start the Playback
MPB.$$LIB
' Set the Playback speed to double speed
MPC.|setrate|2
' Decrease the volume a bit (Range is from 100 - loud, to zero
' - sound off)
MPC.|svol|90
' Now we wait until the sound was played
WRS.
' We drop the result
DRS.
' We end the script.
ENR.
If there was an error during Playback, you will get it as a result of the background task.
Use GRS. for that purpose.
Example:
$$LID=?pfad\Neu Textdatei.mp3
MPB.$$LID|$$RES
WRS.
GRS.|$$RES
MBX.$$RES
The Music-Player will not pop up any error-messages, instead give the error back as a result.
Some Hints:
• Use MPA. in case the Music should play in the background
• Use SVL. to change the Overall Volume and the Mute-State
• Use MPC. and MPB. for Sound effect like faster or slower Playback rate etc.
Syntax
MPB.[P1][|P2]
Parameter Explanation
P1 - Filename or Playlist (=Filenames, separated with ">")
P2 - (optional) Variable, receives Ticket-Number for Result (GRS.)
Example
'***********************************
' MPB.-Sample
'***********************************
' Start the PLayback
MPB.MySong.mp3
GSB.Fade
' Now we wait until the sound was played
WRS.
' We drop the result
DRS.
' We end the script.
END.
:Fade
' Fade Balance from left to right
FOR.$$CNT|-10000|10000|100
MPC.|sbal|$$CNT
NEX.
' Reset Balance
MPC.|sbal|0
RET.
Remarks
-
Limitations:
This command makes use of the Windows "Direct Show" API. If Direct X / Direct Show is not installed on the target PC, these commands will not work. If you have a working Windows Media Player,on the system, then everything will work as expected. Generally all Audio-Formats, that are supported with the Windows Media Player, should work with this command also.
See also: