<< Click to Display Table of Contents >> Navigation: 3. Script Language > Multimedia Commands > Multimedia Commands |
MiniRobotLanguage (MRL)
MPC. Command
Music Player Commands
Intention
MPC. functions as a companion to the MPB. command. It allows you to modify the playback parameters once the audio is playing through MPB.
Therefore, prior to using MPC., it's crucial that you're familiar with the workings of MPB.
The first parameter needed for using MPC. is the "Ticket Number".
By using the "Ticket Number", you gain control over the associated background task.
More information on handling "Ticket Numbers" and managing background tasks can be found at:
"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.5
' Decrease the volume a bit (Range is from 100 - loud, to zero
' - sound off)
MPC.|svol|90
' Fade Balance from left to right
FOR.$$CNT|-10000|10000|100
MPC.|sbal|$$CNT
NEX.
' Reset Balance
MPC.|sbal|0
' Now we wait until the sound was played
WRS.
' We drop the result
DRS.
' We end the script.
ENR.
You can change values dynamically to achieve Sound effects.
Note that such effects may be different on different fast computers.
$$LIB=?path\Lied.mp3
' Start the Playback
MPB.$$LIB
' Now we wait until the sound was played
MPC.|setrate|1.3
MPC.|svol|90
MPC.|gd|$$RET
' Change position and volume dynamically
FOR.$$CNT|0|$$RET|1000
MPC.|sp|$$CNT
FOR.$$VOL|100|77|-1
MPC.|sv|$$VOL
NEX.
NEX.
MPC.|stop
' Reset Balance
MPC.|sbal|0
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
MPC.[P1][|P2]
Parameter Explanation
P1 - Sub-Command. Out of the following:
"Stop" - Stops Playback from the selected background task immediately.
"Pause" - Pauses Playback from the selected background task immediately.
Continue playing using the "Play" Sub-Command.
"Play" - Start Playback of a loaded or Paused Audio-File, from the
selected background task.
"setrate","set rate","set playback rate","sr"
Change the Playback Rate/Speed of the currently selected background task.
The playback rate is expressed as a ratio of the normal speed. Thus, 1.0 is normal
playback speed, 0.5 is half speed, and 2.0 is twice the original speed..
"setpos","set position","sp"
Change the Playback Position of the currently selected background task.
The playback Position is expressed is a 64-bit integer value. To obtain the
maximum absolute position, use the "get duration" command.
"set end position","setend","setendpos","se"
Change the Playback-End Position of the currently selected background task.
The playback End-Position is expressed is a 64-bit integer value. To obtain the
maximum absolute position, use the "get duration" command.
"move","from here","mv"
Change the Playback-Current Position relative to the current position,
of the currently selected background task.
The playback Current-Position is expressed is a 64-bit integer value. To obtain the
maximum absolute position, use the "get duration" command.
Example:
MPC.$$TIN|mv|1000
"moveend","move end","end from here","me"
Change the Playback-End Position relative to the current position,
of the currently selected background task.
The playback End-Position is expressed is a 64-bit integer value. To obtain the
maximum absolute position, use the "get duration" command.
Example:
MPC.$$TIN|mv|1000
"get duration","gd","gdur"
Get the Playback-Duration of the currently selected background task.
The playback Duration is a 64-bit integer value.
Example:
MPC.$$TIN|gd|$$RET
DBP.$$RET
"get position","gpos","gp"
Get the Playback-Duration of the currently selected background task.
The playback Duration is a 64-bit integer value.
Example:
MPC.$TIN|gp|$$RET
DBP.$$RET
"load"
"set volume","svol","setvolume","sv"
Set the Playback-Volume in a Range from 0 to 1000, of the currently
selected background task. The volume steps are not linear, this way you can set
very soft music / sounds more accurate and have less steps for loud sounds.
Example:
MPC.$TIN|sv|100
"set balance","sbal","setbalance","sb"
Set the Playback-Balance in a Range from -10000 to 10000, of the currently
selected background task.
The Balance (left/right speaker) is equal when you set the value to zero.
If you set it to -10000 then only the right speaker is used. If you set it to 10000
then only the left speaker is used. Example:
MPC.$TIN|sb|10000
MPC.$TIN|sb|-10000
"get volume","gvol","gv"
Get the Playback-Volume in a Range from 0 to 1000, of the currently
selected background task. The volume steps are not linear, this way you can set
very soft music / sounds more accurate and have less steps for louder sounds.
Example:
MPC.$TIN|gv|$$RES
DBP.$$RES
"get balance","gbal","gb"
Get the Playback-Balance in a Range from -10000 to 10000, of the currently
selected background task.
The Balance (left/right speaker) is equal when you set the value to zero.
If you set it to -10000 then only the right speaker is used. If you set it to 10000
then only the left speaker is used. Example:
MPC.$TIN|gb|$$RES
DBP.$$RES
P2 - (optional) Variable, receives or contains values, depending on the chosen
Sub-Command.
Example
'***********************************
' MPB. / MPC.-Sample
'***********************************
' Start the PLayback
MPB.$$LIB
' Now we wait until the sound was played
MPC.|setrate|1.3
MPC.|svol|90
MPC.|gd|$$RET
' Change position and volume dynamically
FOR.$$CNT|0|$$RET|500
MPC.|sp|$$CNT
FOR.$$VOL|100|70|-1
MPC.|sv|$$VOL
NEX.
NEX.
MPC.|stop
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:
• MPB. - Music Play Background