If you go with the 99 cent MP3 player and separate amplifier, I dug up photos from earlier threads but collected here with additional comments to summarize one way to do it.
Not necessarily for crossing gates, but since the MP3 player is STEREO, you can play two completely independent sounds. So for a track-side layout sounds that run all the time, just add a 2nd speaker and store sound #1 on the left-channel and sound #2 on the right-channel.
Above shows the guts of the MP3 player. The battery is disconnected and unused. The volume controls are not used; as per the discussion, this player will automatically start playing whatever MP3 file/song/sound is stored on the microSD memory car when power is initially applied.
Above shows the general concept of a MP3 player + audio amplifier + speaker. The battery is not used in your application. Again, these are re-cycled photos. The point here is to put the speaker in a chamber which greatly improves audio performance. Note that the IC amplifier chip (PAM8403) can drive a 4 ohm, 8 ohm, or whatever ohm speaker you have lying around.
Above shows the 1uF capacitor (polarized so mind the + and -) installed in place of the Lithium battery. The player's ON/OFF slide switch is placed in the ON position. 5V DC is applied as shown. These are the same connection points as the +5V and GROUND connections on the mini-USB but the cable is somewhat bulky and by the time you cut, splice, strip, etc. the cable, it's probably easier (and certainly more compact) to just wire in +5V and ground as shown. Ground is soldered to the mini-USB connector tab as shown.
The two audio outputs (if you are even using both), are as shown. It is very important to note that the audio common is not used when the MP3 player is mated to the amplifier module.
Above is audio amplifier module. Capacitor is added as shown; note polarity. Again, note that the audio common (the pad between the two audio inputs) is NOT used when mated with the MP3 player.
Above shows you do not need to use the 3.5mm earbud connector between the MP3 player and the audio amp. You can save substantial space by dispensing with the 3.5mm plug and simply tacking a wire to one (or both if needed) audio outputs as shown. Again, you do not use the common audio output connection.
------------------
Separately, if you want manual volume control you can get what amounts to the same PAM8403 IC amplifier electronics except with potentiometer. Here's how you'd attach the capacitor on the eBay module which is also about $1 shipped. As noted earlier, the capacitor is optional. For a layout accessory sound that is continuously running, I don't think it matters or that you'd even notice the one time pop/click when you power up your layout for an operating session.
The other connections to the MP3 player, speaker(s), 5V DC are the same.
I figure you would only set the volume once for a crossing gate and never change it. So the fixed volume module works fine with any one-time volume setting done by simply modifying the MP3 file itself within a sound-editor (Audacity or whatever).