HTML and CSS Reference
In-Depth Information
<script type=”text/javascript”>
AudioPlayer.setup(“player.swf”, {
width: 325
<p id=”myaudio”><a href=”song.mp3”> Download MP3 file </a></p>
<script type=”text/javascript”>
AudioPlayer.embed(“myaudio”, {soundFile: “song.mp3”} );
FIGURE 12.16
An embedded
audio player.
Audio Player uses JavaScript to embed the player in a target element using a technique
similar to the SWFObject dynamic publishing technique. In the header of the page, I
included the JavaScript file provided with Audio Player and then set up the player in the
next <script> tag. Copy that code and replace the size the size that works for you. (The
player in my example is set to be 325 pixels wide.)
Then in the body of the page, I included a <p> tag that will contain the player. My alter-
native content goes inside the <p> tag. It's replaced when the JavaScript that follows adds
the player to the page. In this case, I added a link that points to the MP3 file that the
player is going to play. Finally, I embedded the player using JavaScript. For it to work, I
specified the ID of the element that will contain the player and specified the location of
the audio file. In this case, it's song.mp3 , found in the same directory as the page.
In this lesson, you learned about the wide world of tags, codecs, and file formats associ-
ated with publishing audio and video on the Web. First, you learned how to upload your
video files to YouTube and publish them on your site. You also learned about some
Search WWH ::

Custom Search