I have added an mp3 file as a static resource, can someone please help me to call that resource in the lightning component so when I hit the button it will play that static resource as per the Salesforce documentation I have tried below but instead of playing the sound it is displaying the message.

enter image description here

  • 3
    ui:message is a TTS service, not for playing arbitrary audio files.
    – sfdcfox
    Sep 10, 2018 at 9:39

3 Answers 3


You can use audio tag and specify source of music file in order to play music in Lightning components. For example :

    <audio src="https://chiraglex-dev-ed--c.ap4.content.force.com/servlet/servlet.FileDownload?file=00P6F00002CXedP" 

You can put this in javascript when a button is pressed.

 var playSound = new Audio(urlAudio);

Play using static resource. Upload a music file to the static resource, copy the link of the file and use in the following fucntion and call it where you want to play the sound.


    var beepsound = new Audio(Static Resource URL);   
    console.log('beep ');


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .