playMusic: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (format)
m (Text replacement - "[] spawn" to "0 spawn")
 
(57 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| ofp |= Game name
|game1= ofp
|version1= 1.00


|1.00|= Game version
|game2= ofpe
|version2= 1.00


|eff= local |= Effects in MP
|game3= arma1
____________________________________________________________________________________________
|version3= 1.00


| Plays music defined in [[Description.ext#Music|CfgMusic]]. To stop the music execute [[playMusic]] "" or give the start time which is beyond the music duration [[playMusic]] ["SomeMusic", 1000];  |= Description
|game4= arma2
____________________________________________________________________________________________
|version4= 1.00


| '''playMusic''' name |= Syntax
|game5= arma2oa
| p1 = name : [[String]] - music class
|version5= 1.50
|[[Nothing]]  |= Return value
____________________________________________________________________________________________
|s2= '''playMusic''' [name, start] |= Syntax 2


|p21= [name, start]: [[Array]] |= Parameter 1
|game6= tkoh
|p22 = name: [[String]] - music class |= Parameter 2
|version6= 1.00
|p23= start: [[Number]] - start from (seconds). Could be negative. |= Parameter 3


|r2= [[Nothing]] |= Return value 2
|game7= arma3
|version7= 0.50


____________________________________________________________________________________________
|eff= local
|x1 = <code>[[playMusic]] "RadioAmbient1";</code> |= Example 1 
|x2 = <code>[[playMusic]] ["RadioAmbient3", 3]; //start from 00:00:03</code> |= Example 2
|x3 = Play from 00:00:01 to 00:00:05<code>0 = [] [[spawn]] {
[[playMusic]] ["RadioAmbient5", 1];
[[sleep]] 4;
[[playMusic]] "";
};</code> |= Example 3


| [[playSound]], [[say]], [[createSoundSource]], [[addMusicEventHandler]] |= See also
|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]]


<h3 style="display:none">Notes</h3>
|x1= <sqf>playMusic "RadioAmbient1";</sqf>
<dl class="command_description">
<!-- Note Section BEGIN -->


<dd class="notedate">
|x2= <sqf>playMusic ["RadioAmbient3", 3]; // start to play from 00:00:03</sqf>
<dt class="note">'''[[User:Crowe|Crowe]]'''
<dd class="note">
You can get all Music Types from [[Arma:_cfgMusic]]
http://community.bistudio.com/wiki/Arma_2:_Music#top


<!-- Note Section END -->
|x3= Play from 00:00:01 to 00:00:05:
</dl>
<sqf>
0 spawn {
playMusic ["RadioAmbient5", 1];
sleep 4;
playMusic "";
};
</sqf>


<h3 style="display:none">Bottom Section</h3>
|seealso= [[getMusicPlayedTime]] [[playSound]] [[say]] [[createSoundSource]] [[addMusicEventHandler]] [[fadeMusic]] [[Arma_3_Utilities#Jukebox|{{arma3}} Jukebox Utility]]
[[Category:Scripting Commands|PLAYMUSICNAME]]
}}
[[Category:Scripting Commands OFP 1.96|PLAYMUSICNAME]]
[[Category:Scripting Commands OFP 1.46|PLAYMUSICNAME]]
[[Category:Scripting Commands ArmA|PLAYMUSICNAME]]
[[Category:Scripting Commands ArmA2|PLAYMUSICNAME]]
[[Category:Scripting Commands Arma 3|PLAYMUSICNAME]]
[[Category:Command_Group:_Sounds|{{uc:{{PAGENAME}}}}]]

Latest revision as of 21:24, 2 September 2024

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:
0 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