Jump to content

Audio files display


IndianaGuy

Recommended Posts

I am looking for a free and easily customized way to display audio files and for the user to be able to download them.

I plan on displaying the files in both mp3 and m4a so both Android and Apple users can listen/download unless there is a better way.

 

Thank you very much. This is not illegal music or anything like that. These are audio files created by my organization and only accessible to our members.

 

Thank you. Any tips or things to check out would be very much appreciated.

 

 

Link to comment
Share on other sites

For listening, you can use the HTML <audio> element. If you want to customize its appearance you will need to generate HTML elements for the controls and add click events to call methods from the HTMLMediaElement interface.

 

For downloading, a direct link to the file works. If you want to force a download you will need a PHP script that sets a Content-Disposition header and then you would link to that script. Here's a basic example, but you might want to adapt it to your specifications:

<?php
$song = 'mysong.mp3';
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment;filename=$song");
echo file_get_contents("files/audio/$song");
exit;
?>
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...