Powered By Blogger

Saturday, 7 May 2011

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:
http://enable-portal-developer-edition.na8.force.com/apex/PlayMP3?id=00QC000001Oqr4J


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:
https://login.salesforce.com/?startURL=%2Fpackaging%2FinstallPackage.apexp%3Fp0%3D04tC0000000YZvS

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

Regards,
Bhawani

30 comments:

  1. Thanks for this Bhawani. A really nice post. Now I can get rid of the process of first downloading the attachment and then listening to it.

    ReplyDelete
  2. 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?

    Thanks,
    Maneesh

    ReplyDelete
    Replies
    1. did you get any input on this..Please help me.i need to do the same in Video

      Delete
  3. nice post. but do you have a static resource for media/movie player?

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. @Eugene: Yes, player is stored as static resource.

    ReplyDelete
  6. 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

    ReplyDelete
  7. i'm trying to find a swf player similar to your player.swf. but i want it to also play videos. thanks in advance

    ReplyDelete
  8. Hi,
    I have install this app in my org. It's really a nice app.
    But this app is not supported all audio formats,it's work only for .mp3 format.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. This comment has been removed by the author.

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

    cheers.

    ps. its complementary to this great install.

    ReplyDelete
  12. Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!

    Salesforce Administrator Training in Chennai

    ReplyDelete
  13. I have installed the package and what I am doing is i attached a file under notes and attachements related list (mp3). I still dont have the inline play button

    ReplyDelete
    Replies
    1. You should change the url of the document in the visualforce page , replace this Url ("https://c.na9.content.force.com/") with your current org url.

      Delete
  14. 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?

    ReplyDelete
  15. Thank you so much for this post. When I demo www.LearningApache.com to people, they fall into ecstasy, and say things like, "I didn't even know you could do something like this." And then they ask for more volume. Is there a way to pass a volume parameter into the player ?

    ReplyDelete
    Replies
    1. Hi Eric, Definitely there should a one. I need to dig into this again as I wrote this blog years ago.

      Delete
    2. You can reach me on "bhawani.sh.sharma@gmail.com" directly.

      Delete
  16. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.
    Salesforce training in Chennai

    ReplyDelete
  17. Hi Bhavi thanks for sharing this.
    But it is not supported in mozilla firefox can u send me any suggestions for dis.

    ReplyDelete
  18. This app can't be installed.
    There are problems that prevent this package from being installed.
    Method does not exist or incorrect signature: Test.startTest() PlayAudio: Method does not exist or incorrect signature: Test.startTest()
    Apex class 'PlayAudio' does not exist PlayMP3: Apex class 'PlayAudio' does not exist

    ReplyDelete
  19. What value do you really bring that benefits your market in ways that your competitors wouldn’t dream of proposing?
    <a href="http://www.appshark.com/salesforce-services/>salesforce services in Dallas</a>

    ReplyDelete
  20. i am getting below error help me

    Method does not exist or incorrect signature: void startTest() from the type TEST PlayAudio: Method does not exist or incorrect signature: void startTest() from the type TEST
    Method does not exist or incorrect signature: void stopTest() from the type TEST PlayAudio: Method does not exist or incorrect signature: void stopTest() from the type TEST
    Apex class 'PlayAudio' does not exist

    ReplyDelete
  21. I am getting this error:

    Invalid conversion from runtime type Case to Lead
    An unexpected error has occurred. Your development organization has been notified.

    ReplyDelete
  22. Still having probleMs getting the inline player to show I've corrected the URL

    ReplyDelete
  23. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
    Learn more about:
    salesforce communities solutions
    salesforce to salesforce migration
    global rollout consulting services
    salesforce service cloud solution

    ReplyDelete