HTML and CSS Reference
<audio id=”audio” src=”media/audio1.mp3” controls></audio>
<input type=”button” id=”playvideo” value=”Play Random Video File” />
<video id=”video” src=”media/video1.mp4” controls></video>
The markup shown in Listing 1-5 renders two buttons, one <audio> tag, and one <video> tag. The
<audio> and <video> tags have their src attribute set to default media files, but later you'll change src
programmatically. The two buttons call server-side code that returns a random media file to be played.
The returned media file is then assigned to the src attribute of the <audio> or <video> tag so as to set the
media files dynamically. Figure 1-24 shows Default.aspx at runtime in IE9.
Figure 1-24. Default.aspx in IE9
Adding Web Methods
Currently, clicking the Play Random Audio File and Play Random Video File buttons doesn't do anything.
You need to write server-side and client-side code to make them functional. Go into the code-behind file
of Default.aspx , and add two web methods called GetAudio() and GetVideo() as shown in Listing 1-6.
Listing 1-6. Web Methods to Be Called from the Client Side
public static string GetAudio()
//write logic to return random audio file