Jump to content

Playing part of an mp3 audio file with fadeout function?

Mark West

Recommended Posts

I am in the process of trying to create a routine that will play the first 30 seconds of a 3 minute audio file at normal volume, and then do a 3 second fadeout. this is the example of what I have so far:

<audio id="audio2" 


which tends to abruptly end the playback. How do I get it to "gracefully" end the playback? I am hoping to include such a routine as part a website that I am working on where I will sell music tracks, and people would be able to click on a track and hear a sample of what's on said track (a sort of "try before you buy" principal). Any assistance will be greatly appreciated. Thanks in advance.

Link to comment
Share on other sites

Javascript should have control over the volume, it would take a bit of time to write the code to do that. Even then, that's not going to stop people from downloading the whole track for free. If you want to show just a sample, use an audio editor (a free one is Audacity) to make a short track with just the part of the song that you want users to hear and add the fadeout in the edited file.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...