source

< html‎ | elements
Jump to: navigation, search

source

This article is Ready to Use.


W3C Recommendation

Summary

Allows developer to specify multiple alternative media resources for media elements, such as <video> and <audio>. It does not represent anything on its own, and is used with src attribute to specify the URL.


Overview Table

DOM Interface HTMLSourceElement

Attributes

  • src = URL potentially surrounded by spaces
    The address of the media source.
  • type = MIME type
    The type of the media source (used for helping the UA determine, before fetching this media source, if it can play it).
    A string that identifies a valid MIME media type, as defined in [RFC2046].
  • media = media-query list
    The intended media type of the media source (used for helping the UA determine, before fetching this media source, if it is useful to the user).
    A valid media query list, as defined in [MediaQueries].

Examples

View live example

HTML

<video controls="controls">
 <source src="http://media.w3.org/2010/05/sintel/trailer.mp4"
         type='video/mp4; codecs="avc1, mp4a"/>
 <source src="http://media.w3.org/2010/05/sintel/trailer.ogv"
         type='video/ogg; codecs="theora, vorbis"/>
 <p>Your user agent does not support the HTML5 Video element.</p>
</video>

Notes

Remarks

Note  If you change the media file using the src property on an audio or video object, you need to call the load method before calling the play method. If you change the src and call the play() method without loading first, it will continue to play the file specified by the source element.


Related specifications

Specification Status Related Changes
HTML 5.1 W3C Working Draft
HTML 5 W3C Recommendation

See also

Related pages (MSDN)

  • audio
  • video

Attribution

This article contains content originally from external sources.

Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]