Salesforce: Play Attachments on the same page


I came back again with a very interesting thing this time.
These day I worked a lot with the attachments and realized that if we have any audio/video attachments in org then to see them first we need to download it on local machine and only then we can play with it.I wanted to build a script which can  play attachment in the salesforce itself without asking for download. 

Now the question is how this is useful :
I had a voice call with the customer and attached this call with the customer record. Now after some days I want to confirm a point was discussed in the call. So what I need to do :

  • Go to the customer record.
  • Click on the attachment.
  • Download the attachment.
  • Save on local disk.
  • Play audio.
  • Delete file once audio done to escape from the unnecessary storage on machine.

So here you can see that, there will be 6 step to listen a audio file, while we just wanted to hear the discussion again. These step will be always be repeated whenever we want to listen this conversation.

So if there could be a utility which could play the files in org itself without asking for downloading, that would be better. That’s whay I started work on this idea and now here I am.
I have created a visualforce page and embedded this with some JS files, which allow to play the audio files on the same screen. This shows a player only with the audio file in the same row. Check it here:

This page can be added as inline Visualforce page with any object which supports attachments.Like :

I have created a Un-managed package for this. So you can modify this as per your requirement.
Here is the URL:

Please comment if any modification can be done to make it better.


22 thoughts on “Salesforce: Play Attachments on the same page”

  1. Great Post Bhawani. I am trying to do something similar. My audio files are not stored as attachments, but are retrieved through an APEX CallOut to a .NET web service. The web service sends the audio blob as a base64binary (its a byte array that gets serialized like this). The helper controller class retrieves this string and displays in VF page byte-for-byte correct. The problem comes when I try to play this content by using a mime type of audio/wav in the VF page. At that time the player does not decode the blob properly. I have tried doing a base 64 decode to convert the string to a blob before rendering, but it does not help.

    Any ideas on how I can handle this?


  2. thanks bhavi. i mean, what you used here is a audio player, it can only play sound files. what if i want to play a video? do you have a file other than a audio player that will allow me to play video attachments?it would really help alot. thank you

  3. Hello Bhavi:

    Is it possible that you can share the visualforce page of how to add the static resource you have? I tried to click on the first link and got the error of asking me to login. Thanks.

  4. I've tried posting my contribution to the blog, the video player. No success, so, email me if you want it.


    ps. its complementary to this great install.

  5. I like this example. How would I modify it to play audio from a custom object rather than the lead object? Can it play wav files, or just mp3?

Leave a Reply

Your email address will not be published. Required fields are marked *