/playsound
< Commands
/playsound| Permission level required |
|
|---|---|
| Restrictions |
Cheat only |
{
"title": "<code>/playsound</code>",
"rows": [
{
"field": "\n* 2 <sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Java Edition\">(link to Java Edition article, displayed as JE) only</span></i>]</sup>\n* 1 <sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Bedrock Edition\">(link to Bedrock Edition article, displayed as BE) only</span></i>]</sup>",
"label": "(link to Permission level article, displayed as Permission level<br>required)"
},
{
"field": "(link to Options article, displayed as Cheat) only<sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Bedrock Edition\">(link to Bedrock Edition article, displayed as BE) only</span></i>]</sup>",
"label": "(link to Commands#Restrictions article, displayed as Restrictions)"
}
],
"invimages": [],
"images": []
}
Plays a specified sound to a player, in a location, and in a specific volume and pitch.
Syntax
- Java Edition
playsound <sound> [<source>] [<targets>] [<pos>] [<volume>] [<pitch>] [<minVolume>]
- Bedrock Edition
playsound <sound: string> [player: target] [position: x y z] [volume: float] [pitch: float] [minimumVolume: float]
Arguments
JE: <sound>: resource_location
BE: sound: string: basic_string
- Specifies the sound to play.
- In Bedrock Edition, must be a string. And it must be a single word that has no space or a double-quoted string (When quoted,
\can be used to escape characters). Should be a sound definition defined in sound_definitions.json (for example,mob.pig.say). - In Java Edition, must be a resource location for an unregistered content. Should be a Sound Event defined in sounds.json (for example,
entity.pig.ambient). - A sound event may be affiliated with multiple sounds, and the sound that is actually produced is chosen at random from them, modified by their "weight", just as the game normally would. For example, the
entity.pig.ambientsound event plays one of several pig sounds at random, because the event has multiple sounds associated with it. - Resource packs may add their own events to sounds.json; the command successfully plays these. File names are not used by this command; it strictly uses the events defined in sounds.json (which may not even be similar to the original file names and paths), and thus a resource pack adding new sound files must define events for them (this is not necessary when replacing old sounds already defined in events).
JE: <source>
- Specifies the music category and options the sound falls under. Must be
master,music,record,weather,block,hostile,neutral,player,ambient,voice, orui. If omitted,masteris used.
JE: <targets>: entity
BE: player: target: CommandSelector<Player>
- Specifies the player(s) for whom the sound is going to be played. If not specified, defaults to the player who executes the command.
- Must be a player name, a target selector or a UUID. And the target selector must/should be of player type. In Bedrock Edition, the target selector should be of player type.
JE: <pos>: vec3
BE: position: x y z: CommandPositionFloat
- Specifies the position to play the sounds from.
- Must be three-dimensional coordinates with double-precision floating-point number or single-precision floating-point number elements. Accepts tilde and caret notations.
JE: <volume>: float
BE: volume: float: float
- Specifies the distance that the sound can be heard. If not specified, defaults to 1. For values less than 1, the volume diminishes. For values greater than 1, the sound does not actually grow louder, but its audible range (a 16-block radius at 1) is multiplied by volume. There is always a gradual falloff to silence based on distance from the center of the sphere. For values equal to or less than 0, no player can hear the sound.
- Must be a [Float]Single-precision floating-point number (from -(2-2-23)×2127 (≈-3.4×1038) to (2-2-23)2×127 (≈3.4×1038) ). In Java Edition, it must be greater than or equal to 0.0.
JE: <pitch>: float
BE: pitch: float: float
- Specifies the pitch and speed of the sound. If not specified, defaults to 1.
- Must be a [Float]Single-precision floating-point number (from -(2-2-23)×2127 (≈-3.4×1038) to (2-2-23)2×127 (≈3.4×1038) ). In Java Edition, it must be between 0.0 and 2.0 (inclusive).
- In Java Edition, values less than 0.5 are equivalent to 0.5. Values lower than 1 lower the pitch and increase the duration; values greater than 1 raise the pitch and reduce the duration. The pitch value is a multiplier applied to the frequency, so if a value from 0.5 to 1 is doubled, the pitch goes an octave higher. (See Note block § Usage for converting other intervals to pitch values, but be aware that 1 isn't F♯ for all sound effects.)
- In Bedrock Edition, only values between 0 and 256 work. Values above 256 are equivalent to the default value; values less than 0 default to 1, while values equal to 0 makes the sound inaudible. The value of the pitch is also the value for the speed multiplier, ex. if you set the pitch to 2 then the sound will play at double the pitch and double the speed.
- Notice that in Bedrock Edition, if you try to set a pitch value to a sound, then the speed of playing sound will be changed in turn. And the speed multiplier is just the value of this argument.
JE: <minVolume>: float
BE: minimumVolume: float: float
- Specifies the volume for targets outside the sound's normal audible sphere. If a target is outside the normal sphere, the sound is instead centered some short distance (two blocks away) from the target, and this argument determines its volume. If not greater than 0, targets outside the normal audible sphere cannot hear the sound.
- If not specified, defaults to 0.0.
- Must be a [Float]Single-precision floating-point number (from -(2-2-23)×2127 (≈-3.4×1038) to (2-2-23)2×127 (≈3.4×1038) ). In Java Edition, it must be between 0.0 and 1.0 (inclusive).
Result
| Command | Trigger | Java Edition | Bedrock Edition |
|---|---|---|---|
| Any | The command is incomplete, or any argument is not specified correctly. | Unparseable | Unparseable |
player: target is a target selector that is not in player type. | N/A | Failed | |
<targets> or player: target fails to resolve to one or more online players. | Failed | ||
Nobody can hear the sound (minVolume or minimumVolume: float is not greater than 0.0, while all the targets are outside the normal audible sphere). | |||
| One of the specified players cannot hear the sound. | N/A | ||
| Otherwise | Successful | ||
Output
| Command | Edition | Situation | Success Count | /execute store success ... | /execute store result ... |
|---|---|---|---|---|---|
| Any | Java Edition | On fail | 0 | 0 | 0 |
| On success | 1 | 1 | the number of players who can hear the sound | ||
| Bedrock Edition | On fail | 0 | N/A | N/A | |
| On success | the number of targeted players | N/A | N/A |
Examples
- To play the creeper hissing sound 3 blocks behind the nearest player:
History
| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 1.6.1 | pre | Added /playsound. | |||||
| 1.9 | 15w49a | /playsound now accepts tab-completion. | |||||
| 16w02a | /playsound now requires a source parameter, specifying what is the sound's category for volume purposes. | ||||||
| 1.20.5 | 24w09a | Can now be used without specifying the player (assuming @s) and without specifying the mixer (assuming master). | |||||
| 1.21.6 | Pre-Release 3 | Added new category ui. | |||||
| Pocket Edition | |||||||
| 1.0.5 | alpha 1.0.5.0 | Added /playsound. | |||||
See also
/stopsound— Stops a sound.