create your own

How to add an audio file to your website

79
rate or flag this page

By hot dorkage


Introduction

There has been audio on websites since the early days of the web. It has historically been awkward and not always cross browser compatible. There have also been many ways to put audio in a website. I suspect I have tried all of them. What I am going to describe to you in this hub is a modern way to have an mp3 audio file with an embedded player that works slick and also works on most browsers. The process basically consists of two pieces:

  • creating the audio in the first place
  • embedding the audio in a web page

If you already have an mp3 file ready to rock and roll, you can skip the recording section and move directly to the embedding section. I wish to warn you, however, to please be mindful of copyrights when publishing audio media that you didn't create. Duplicate content detection is getting better and better as we speak; and I'd bet that duplicate audio is not that far behind duplicate graphics and duplicate text detection. I would also beg you to please be considerate of your web visitor and never never use an autoplay setting to blast the audio at your visitor as soon as your page loads. This is considered extremely rude, and many surfers will leave your page immediately if you do it. Let the visitor choose to play the audio, and you will have many more friends.

As an aside, it would be great if Hubpages wrapped audio functionality in its interface and let us create audio capsules; if that were possible I'd put an example of one right here and let you try it. However, within HubPages' current technical limitations, that's not possible, so I'll put a picture of what an audio player looks like and refer you later to a working example on a third party site.

Okay, having issued those warnings and digressed a bit, let's get on with it.

Player graphics

Click thumbnail to view full-size
These are my colors; you can choose whatever colors you like.  :)
These are my colors; you can choose whatever colors you like. :)



Recording

You can use either a standalone digital audio recorder or you can use a software recorder on your PC. I have used both. If you use a standalone digital audio you can post process with your audio recording software. My favorite recording software is a piece of extremely powerful freeware called Audacity. It is available from http://audacity.sourceforge.com and there are versions for Windows, Mac, and even Linux.

If you do not use a separate recorder, you will also need a microphone to use with Audacity or any other direct recording software you have. Librivox have detailed descriptions of recommended recording equipment for speech and a couple models to avoid. Here are the Librivox recommendations on equipment.

Whether you record to a digital recorder or not, you will probably end up using Audacity to splice or do voiceovers. It is incredibly easy to use -- to record, you basically open the application to a new blank window, hook up your mike, and start making noise. To splice, you open up the two files in separate windows, then just cut and paste the data from one after the tail end of the other. Check out the tutorial video below on using Audacity. I'd like to point out that Audacity can directly export to mp3--no need to run it through some web converter as the tutorial suggests.

If you are doing a speech recording, it is a nice professional touch to frame it with your audio brand. This can be a signature music clip or sound effect. It is also a good idea to finish with an ending clip cut from the same cloth. You can reuse these frame clips to build audio brand recognition.

Audacity Screenshot

Audacity window after recording.  The data is the sound data.
Audacity window after recording. The data is the sound data.

Podcasting with Audacity

Embedding Audio

Now for the part you been waiting for: How to make that cool little player pop up on your web page. It does require that you have some measure of control over your website on the server, that is to say, be able to specifically upload files to it, either that or your content management system (CMS) has to have an interface for audio, and the procedure for doing that would be specific to and different for each CMS. And example of a CMS is hubpages itself. Unfortunately hubpages currently does not provide an interface to include audio. So I am describing the most basic way to do it: upload some files to your server and then set up the html code to invoke the player to play your audio.

Wordpress Blogging software is a popular CMS of sorts that has a plugin for dealing with audio. That's nice if you happen to have a wordpress blog, but if you don't, you can download it anyway from 1pixelout.net, cannibalize the working guts of it and set up the html code block by hand. It is more tedious than difficult. After you've downloaded and unpacked the plugin package you will find several files in it. The worker bees are called audio-player.js and player.swf. Create a folder in your website with the suggested name of audio. Dump those two worker files from the plugin package in there, and also your mp3 file, let's say it's named audioblog.mp3. Now, all you have to do is put the following block of html code on your webpage where you want the player to appear (changing all the URL's of course to match your domain.

<script language="JavaScript" src="http://www.fakedomain.com/myname/audio/audio-player.js"></script> <object type="application/x-shockwave-flash" data="http://www.fakedomain.com/myname/audio/player.swf" id="audioplayer1" height="24" width="290"> <param name="movie" value="http://www.fakedomain.com/myname/audio/player.swf"> <param name="FlashVars" value="playerID=1&soundFile=http://www.fakedomain.com/myname/audio/music.mp3"> <param name="quality" value="high"> <param name="menu" value="false"> <param name="wmode" value="transparent"> </object>

 


Conclusion

There you have it. Once you have set up the audio folder, you don't have to reupload the worker files to it each time you add another audio file. You can just dump the audio file in with his brothers, then modify the html block accordingly to have it's URL for the playfile. One final little thing to note: If you have more than one audio player on a web page you have to give them different id's. As with most errors I've BEEN THERE, DONE THAT. If you try this and you run into any trouble, I'm happy to help you out. Members of my club can contact me directly, and non members, please just leave a comment and we'll try to get your website making some noise.

About the author:

Colleen Dick is a long time webophile who was experimenting with multimedia on web pages before mp3 or flash even existed. If you would like to see some further musings on multimedia, visit her hot dorkage blog and see working examples embedded right in the blog, and other interesting audio how-to's.

Comments

RSS for comments on this Hub

hot dorkage profile image

hot dorkage  says:
16 months ago

What? Nothing to say? Nobody gonna try to tell me they know a better way, or that I'm all wet or that their boobs are bigger than mine? There is no comment repellent here. What is here is just a little stain of brain juice, and it's not toxic. I promise; it's actually GOOD for ya!

Research Analyst profile image

Research Analyst  says:
15 months ago

Thanks HD, I really can use this information. I am building a new website and I want to use my voice, so visitors can listen to some of my blogs, interviews and local city highlights. Keep up the good work.

hot dorkage profile image

hot dorkage  says:
15 months ago

Thank you for the comment RA, I am really hurting for comments here because I am a mind numbingly analytical geek (boring to everyone but other geeks) but if u need any help don't hesitate to ask. I look forward to hearing your personality come through on your blogs. Too bad we cant put them on hub pages.

guidebaba profile image

guidebaba  says:
15 months ago

This is good job. Many people don't know how to add audion files to their site. I did this long back on my Company's website. And just because you wanted to know: Urad dal sabut = whole black gram.

You can learn more here:

http://hubpages.com/hub/Cooking---Glossary

Mike  says:
3 months ago

Thanks for this. I've been looking everywhere for something like this. I'm sure people going to my site appreciate it too because I originally had the audio playing everytime the site came up.

Tris  says:
2 months ago

This is exactly what I've been looking for! Amazingly I expected a real hassle before searching but found you and your info, used it and very quickly it was working. You are the best audio 'geek' on the web! Cheers greatly. Well written and perfect to follow and get working.

I hoped you could elaborate on the ID tags as I am about to put around 7 players on my site. I would love a quick guide like above if possible?

Also, do you happen to have a code with easy modification to add color, fwd and reverse buttons? I'm trying to use the stand alone info page but am a bit stuck?

Again - one of the best tutorials I've ever used. !

hot dorkage profile image

hot dorkage  says:
2 months ago

I'll answer you here Tris. I think this particular player is pretty much as you see it -- I don't think you can do a FF or reverse. The colors you can set up with parameters -- see my hot dorkage link in the tutorial for an example. for diferent id's f you have > 1 on a page you need to modify the id= in the javascript and make them all different. If I recall correctly it really doesn't matter what you call them.

Tris  says:
2 months ago

Colleen.

You the best! Cheers. :)

hot dorkage profile image

hot dorkage  says:
2 months ago

Tris, I tried to email you back with the addy you specified but it didn't work. I'll try one more time. Anyway I'm glad it's working for you.

Tris  says:
2 months ago

Hi Coleen, sorry I did not get an email. I'll send you my email again. Cheers! but it is working great now you can check the site to see if you wish. Your info is the best - have a good one!

Glenn Stok profile image

Glenn Stok  says:
2 weeks ago

Wonderful!!! Worked perfectly!!! I followed your instructions to install the embedded audio player on my web site. Then I made a test page with three players, each one playing a different mp3 file. Everything went really well.

I like the fact that this player waits to be played on demand only. That is the only reasonable way to have it. Otherwise people will get upset if sound starts automatically.

It would be neat if we had an audio capsule on Hubpages. I am working on my 4th hub, this one about singing Karaoke and I was thinking of placing a few links to mp3 files of 'me' singing. Ha Ha.

Thanks for this hub.

hot dorkage profile image

hot dorkage  says:
2 weeks ago

Yah I asked for an audio capsule ages ago. They can't figure out how it would add value for their monetization is my guess why they don't have one.

Mamta  says:
2 weeks ago

I have a standalone player embedded into my website and i need it to play a file after automatically downloading it over the internet. My mp3 file url looks something like this

https://websiteName.com/listen.php?id=randomNUmber

If i open this link , i get an mp3 file. Downloading it manually and then playing it over the embedded player works however it doesnt work if i enter this link directly into the soundFile="link".

Please help.

Thanks,

Mamta

hot dorkage profile image

hot dorkage  says:
2 weeks ago

The javascript can't resolve dynamic stuff like that. You would need to write a serverside script to resolve the listen.php?id=xxx to an actual mp3 file, upload it to your own web, then dynamically generate the player code, i.e., you need to embed direct static links directly to the actual target files. If you don't know how to do this I can do it for you as a professional service.

Mamta  says:
2 weeks ago

Thank you so much for your help. I am going to try and do this today!!

Mamta

Submit a Comment

Members and Guests

Sign in or sign up and post using a hubpages account.


optional


  • No HTML is allowed in comments, but URLs will be hyperlinked
  • Comments are not for promoting your hubs or other sites

working