LexiConn Knowledgebase

Knowledgebase Home | Favorites Knowledgebase Home | Favorites
Search the Knowledgebase Browse by Category
How do I stream or add an audio file to my site?
Article Details

Last Updated
8th of September, 2008

User Opinions (299 votes)
98% thumbs up 1% thumbs down

How would you rate this answer?
Helpful
Not helpful

Streaming is a term that is frequently misused to describe deploying any media on the web. Authentic streaming requires the use of a streaming server dedicated to serving media files, frequently using a protocol other than HTTP (such as rtsp) to improve performance. There are no streaming servers available to LexiConn clients; however, you can still include both audio and video in your pages.

You do not need to be as concerned with file size using audio files as you are with video files because they can be compressed to a much smaller size; however, there is no universal method of including audio on a page, and browsers plugins can handle audio in unprdictable ways. Here are a few methods of including audio on your pages, along with the Pros and Cons of each:

1. Include audio files as regular HTML links on your page

Example: <a href="myaudiofile.mp3">Play Sound</a>

Pros: Very simple to embed the audio file in the page

Cons: Almost always opens up the user's default media player to play the file (it can be quite disruptive to a user's experience on your site if a full-screen instance of Windows Media Player opens in front of you web page to play an eight-second audio file)

2. Include audio using the <embed> tag

Example: <embed src="myaudiofile.mp3" autostart="false" loop="false" />

For compatibility with older versions of Internet Explorer that don't support <embed> you can include a <noembed> tag immediately following the <embed> tag and use the <bgsound> tag (supported only by Internet Explorer) like this:

<embed src="myaudiofile.mp3" autostart="false" loop="false" /> <noembed><bgsound src="myaudiofile.mp3"></noembed>

Pros: This method will typically allow for the audio file to be played directly in the browser (without opening an external program);

Cons: Browsers may require you to install a plugin to play the audio file; because the audio file has no dimensions, it is difficult to control the space the browser will allocate for the player on the page;

3. Include audio file using the Flash JavaScript API

The easiest way to use this method is to use SoundManager2, a Javascript library that interfaces with the Flash audio API making it easier for you to interact with your audio files:


Documentation on using the SoundManager 2 library can be found at:


A sample JavaScript include using the library would look something like this:

<script type="text/javascript" src="[/path/to/soundmanager2.js]"></script>
<script type="text/javascript">
	soundManager.url = '[/path/to/sm2-flash-files/]';
	soundManager.onload = function() {	
		soundManager.createSound('myaudiofile.mp3','/path/to/myaudiofile.mp3');
		soundManager.play('myaudiofile');
	}
</script>

Pros: audio processing is one of the greatest weaknesses of browsers. Browser plugins handle audio unpredictably while Java Applets are restricted to 8-bit sound (remember those first-generation digital answering machines?). There is, however, one more tool we have, and that;s the Flash JavaScript API. Since Flash is available to more than 96% of browsers, can dynamically adjust download speed, and present audio from within your browser, it makes the most sense to use this method.

Cons: Requires some fairly simple JavaScript coding

4. Include audio files as a playlist (.m3u)

Example: <a href="music.m3u" type="audio/x-mpegurl">Play music clip</a>

1. Use an ascii editor (e.g. Notepad or SimpleText) to create a playlist.m3u file with the full url to the actual mp3, for example:

http://your_domain.com/myaudiofile.mp3

Or you can add multiple audio files to your playlist by entering one-per-line, like this:

http://your_domain.com/myaudiofile.mp3
http://your_domain.com/myaudiofile_2.mp3
http://your_domain.com/myaudiofile_3.mp3
http://your_domain.com/myaudiofile_4.mp3

2. Upload the m3u file to the web server using ascii mode in your FTP program.

3. Upload the mp3 file to the web server using binary mode in your FTP program.

Pros: Easy to configure and offer multiple audio files.

Cons: Less control over the media player used for playback; could possibly launch an external application to play the files



Related Articles
Attachments
No attachments were found.

Powered by Interspire Knowledge Manager Knowledgebase Software