How to 'force' Minecraft music to play?

I have taken a look at these two answers but they do not mention a way to force the Minecraft music to play: [1] [2]

I was wondering if there is a way to 'force' music to play, whether this is achieved through datapacks, commands, or simply by walking to a specific area under specific conditions to make it happen.

Does anyone know if there is any way of doing this?


Solution 1:

You can force Minecraft music to play with the /playsound command.

Syntax:

playsound <sound> <source> <targets> [<position>] [<volume>] [<pitch>] [<minVolume>]

For example:

/playsound minecraft:music.creative music @s ~ ~ ~ 999999

(The volume is not how loud the sound is, but how far from the source you can still hear it. Since you probably don't want the music to fade when you move away from the position, it is set to an extremely high number.)


Using Minecraft's autocomplete feature, if you type in:

/playsound minecraft:music.

...a list of options will appear, and you can select which one you like.