playMusic: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
 
m (Text replacement - "Arma 3 CfgMusic" to "Arma 3: CfgMusic")
 
(69 intermediate revisions by 12 users not shown)
Line 1: Line 1:
'''playMusic''' can refer to these scripting commands:
{{RV|type=command
*[[playMusic name]] - format is <code>playmusic name</code>
*[[playMusic nameAndpos]] - format is <code>playmusic [name,position]</code>


{{Disambig}}
|game1= ofp
|version1= 1.00
 
|game2= ofpe
|version2= 1.00
 
|game3= arma1
|version3= 1.00
 
|game4= arma2
|version4= 1.00
 
|game5= arma2oa
|version5= 1.50
 
|game6= tkoh
|version6= 1.00
 
|game7= arma3
|version7= 0.50
 
|eff= local
 
|gr1= Sounds
 
|descr= Plays music defined in [[Description.ext#CfgMusic|Description.ext's CfgMusic]] or config.cpp. If the ''musicName'' could not be found a message is logged into the .rpt file: {{hl|Music <''musicName''> not found}}.
* [[Arma 3: CfgMusic]]
* [[Arma 2: CfgMusic]]
* [[ArmA: Armed Assault: CfgMusic]]
* [[Operation Flashpoint: CfgMusic]]
 
{{Feature|informative|To stop the music, use <sqf inline>playMusic "";</sqf>.}}
 
|s1= [[playMusic]] musicName
 
|p1= musicName: [[String]] - music classname
 
|r1= [[Nothing]]
 
|s2= [[playMusic]] [musicName, start]
 
|p21= musicName: [[String]] - music classname
 
|p22= start: [[Number]] - start, in seconds. Can be negative.
 
|r2= [[Nothing]]
 
|x1= <sqf>playMusic "RadioAmbient1";</sqf>
 
|x2= <sqf>playMusic ["RadioAmbient3", 3]; // start to play from 00:00:03</sqf>
 
|x3= Play from 00:00:01 to 00:00:05:
<sqf>
[] spawn {
playMusic ["RadioAmbient5", 1];
sleep 4;
playMusic "";
};
</sqf>
 
|seealso= [[getMusicPlayedTime]] [[playSound]] [[say]] [[createSoundSource]] [[addMusicEventHandler]] [[fadeMusic]] [[Arma_3_Utilities#Jukebox|{{arma3}} Jukebox Utility]]
}}

Latest revision as of 18:34, 26 June 2023

Hover & click on the images for description

Description

Description:
Plays music defined in Description.ext's CfgMusic or config.cpp. If the musicName could not be found a message is logged into the .rpt file: Music <musicName> not found.
To stop the music, use playMusic "";.
Groups:
Sounds

Syntax

Syntax:
playMusic musicName
Parameters:
musicName: String - music classname
Return Value:
Nothing

Alternative Syntax

Syntax:
playMusic [musicName, start]
Parameters:
musicName: String - music classname
start: Number - start, in seconds. Can be negative.
Return Value:
Nothing

Examples

Example 1:
playMusic "RadioAmbient1";
Example 2:
playMusic ["RadioAmbient3", 3]; // start to play from 00:00:03
Example 3:
Play from 00:00:01 to 00:00:05:
[] spawn { playMusic ["RadioAmbient5", 1]; sleep 4; playMusic ""; };

Additional Information

See also:
getMusicPlayedTime playSound say createSoundSource addMusicEventHandler fadeMusic Arma 3 Jukebox Utility

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note