There is a simple link
<a href="some.mp3">01. The Name of Track</a>
How to play the mp3 file, when user clicks on link? Please help me to find some simple and effective solution. Thank you.
Thank you for help.
I choosed this solution http://www.schillmania.com/projects/soundmanager2/demo/play-mp3-links/ as the most appropriate in my case.
To link to an MP3 file, you must first upload the MP3 file either to a cloud storage service like Google Drive or iCloud, or to an online music service like SoundCloud. After uploading the music, you can share it via the link.
Linking to a sound file using a href allows a browser to open and play an audio file if the viewer of your web page has properly configured their Internet browser. You can also use the <embed> tag or the newer <audio> tag to insert a sound file directly into a web page.
Just mark the “Embed” checkbox and press the Translate & Speak & Embed button. Translate & Speak will create an audio link ready to be embedded. Click "Copy" to copy the link to email a voiced message or embed the audio link to your website.
Use HTML5 <audio>
<audio controls id="linkAudio">
<source src="demo.ogg" type="audio/ogg">
<source src="demo.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<script>
document.getElementById("link_id").addEventListener("click", function () {
document.getElementById("linkAudio").play();
});
</script>
Note: As audio is an HTML5 tag, it won't support old browsers, so be sure before you use it..
Or take a look at this article
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With