<apex:page docType="html-5.0" standardController="Task">
        <audio controls="true" preload="auto">
            <source src="https://mydomain.salesforce.com/servlet/servlet.FileDownload?file=0698c00000Allk9AAB"/>
  <!--  <apex:outputLink value="https://mydomain.salesforce.com/servlet/servlet.FileDownload?file=0698c00000Allk9AAB" id="theLink" type="audio/mp3" rendered="" >Play Recording (mp3)</apex:outputLink>-->

enter image description here

  • Did you upload the file in Classic. If so the file id should be starting with "00P" and it worked for me Commented Aug 16, 2022 at 7:50
  • @SaiPraveenKakkirala I have uploaded the file from apex code in to files and I want it to work on Task record page (thats what business wants) . cv.versionData = response.getBodyAsBlob(); but when i open files in Lightning, i dont see a preview
    – Mentee
    Commented Aug 16, 2022 at 14:50
  • Just click on the file and onclick download button so it opens in new tab where it play the music . Then copy that url and use it in src. But you need to enable the feature mentioned below before that. Commented Aug 16, 2022 at 14:56
  • how to mention type from apex
    – Mentee
    Commented Aug 16, 2022 at 14:57
  • If you upload the file from apex I hope the type will always be File but not attachment. Commented Aug 16, 2022 at 14:58

1 Answer 1


If the file is attached as type "File" then you need to give permission for playing the file in browser as below.

Go to Setup-> File Upload and Download Security->edit and update the mp3 setting as "execute in browser". Then only you will be able to play the file in browser.

Now go to file which you want to play and click on download mp3 button and you will see the url copy the url in the vf page. The Url looks like below.

   <source src="https://domain-dev-ed.file.force.com/sfc/servlet.shepherd/version/download/0685j00000Bj2HF?asPdf=false&operationContext=CHATTER"/>

If the file is upload as type attachment then anyway the file url will play as it is as the id starts with "00P".

<source src="https://sampledomain123-dev-ed.file.force.com/servlet/servlet.FileDownload?file=00P5j00000BvwlN" />

You can find the difference between both as shown in screenshot.

Also as discussed in the comment section we need to enable the above feature if we use Iframe as well

enter image description here

  • I did change the setting from "hybrid" to "execute in browser" in LIghtning (no preview) i switched it to classic (no preview). I copied the link from classic and try to do preview the visualforce page, not working
    – Mentee
    Commented Aug 16, 2022 at 15:04

You must log in to answer this question.

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