Print this Section

  
  

Playing Video

There are no significant differences between accessing and playing video files versus audio files. Video files can be downloaded from the Web for local playback. Files in AVI and MPG formats are the most common types for downloads. Video files in WMV format can be streamed from a media server. These can be live broadcasts or digitized files for on-demand retrieval.

Linking and Embedding Video Files

A video file is downloaded by creating an <a> link with the URL to the file. The file is downloaded and opened in the external Media Player in the same fashion as for audio files.

The following link connects to a WMV video file appearing in the same directory as this Web page. When the link is clicked, the file opens in the external Media Player. The exact manner in which the Media Player appears on your desktop depends on how it is configured.

Casablanca Casablanca.wmv (484 KB)

Figure 9-8. Links to play a video file.

    <a href="casablanca.wmv"><img src="casablanca.gif" alt="Casablanca"/></a>
    <a href="casablanca.wmv">Casablanca.wmv (484 KB)</a>

Listing 9-9. Code to link to video file.

Video files can be embedded in a Web page by using the <video> tag in HTML5. The following example is from w3.org - HTML5 Video Events and API

Figure 9-9. Using a video tag to play video files.

    <video id='video' controls preload='none' mediagroup='myVideoGroup'
        poster="http://media.w3.org/2010/05/sintel/poster.png">
        <source id='mp4' src="http://media.w3.org/2010/05/sintel/trailer.mp4" type='video/mp4'>
        <source id='webm' src="http://media.w3.org/2010/05/sintel/trailer.webm" type='video/webm'>
        <source id='ogv' src="http://media.w3.org/2010/05/sintel/trailer.ogv" type='video/ogg'>
        <p>Your user agent does not support the HTML5 Video element.</p>
    </video>

Listing 9-10. Code to use a video to play video files.

Accessing Video Streams

With availability of URL addresses for external sites, you can link to streamed video content. As with audio files, you may be able to grab the URL from the link if the video is playing through Windows Media Player. While the video is playing, right-click on the screen and choose "Properties" from the pop-up menu. From the Properties window, copy the full URL for the file being streamed.

The following embedded video is linked by this technique. In this case, the URL points to a movie trailer located through a Web search.

Figure 9-10 Embedding a streamed video file.

    <object id="PlayerX" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="width:400px; height:300px">
		<param name="url" value="http://www.youtube.com/v/VsvaFxkXrbg&hl=en_US&fs=1&"/>
		<param name="autostart" value="False"/>
		<!--[if !IE]>-->
		<object data="http://www.youtube.com/v/VsvaFxkXrbg&hl=en_US&fs=1&" id="PlayerX" style="width:400px; height:300px">
			<param name="url" value="http://www.youtube.com/v/VsvaFxkXrbg&hl=en_US&fs=1&"/>
			<param name="autostart" value="false"/>		
		</object>
		<!--<![endif]-->	  
		<p>A sample Video Stream</p>
	</object>

Listing 9-11. Code to embed a streamed video file.

Many Web-based video files have costs or fees for viewing. Also, you will often encounter video players embedded in pages of the site with settings that do not permit access to the Properties window for extracting URLs. You will simply need to be patient and persistent to find video to which you can link. Moreover, URLs are changed routinely. Later you may not be able to link to the video at its original location.

Live video streams can be captured and played through the Media Player. The object tag can be further used for live video streams.


TOP | NEXT: Third Party Content