Condividi tramite


Delivering and Accessing Media Content

Microsoft Silverlight will reach end of support after October 2021. Learn more.

This topic describes steps that you need to perform to deliver and access media content in Silverlight.

Definitions

This section defines a several terms related to delivering and access media in Silverlight. For more information on supported technologies in Silverlight, see Supported Media Formats, Protocols, and Log Fields.

Delivery Technology

Delivery technology is how media is delivered to users. Some examples of delivery technologies include the following:

  • Progressive Download: Delivers media by playing the downloaded portion of a file while the download is still in progress.

  • Traditional Streaming: Delivers and presents media without first storing it.

  • Smooth Streaming: Similar to traditional streaming except that it enables streaming to scale depending on user's hardware and network connection. This is provided by IIS 7 server.

  • SSPL (Server-Side Playlist): A sequence of media assets (either audio or video) that allows server administrators to control the sequence of media viewed by users. For more information, see Server-Side Playlists.

  • ASX: Client side playlists. For more information, see the "Playlists" section of Supported Media Formats, Protocols, and Log Fields.

Container

A container, also called a wrapper format, stores media samples and any associated metadata needed to access it. Some examples of containers include the following:

  • MP4 (ISO MPEG-4 Part 14): A container format derived from the ISO Base Media format MPEG-4 Part 12. Common extensions for MP4 files include MP4, M4A, and M4V.

  • PIFF (Protected Interoperable File Format): A container format derived from MPEG-4 Part 12, designed for smooth streaming and DRM interoperability. IIS uses the extensions ISMA and ISMV.

  • ASF (Advanced Systems Format): A container format created by Microsoft, designed primarily for storing and playing digital media and transmitting digital media over networks. Common extensions for ASF files include ASF, WMA and WMV.

Codec

A codec is a standard for compression and decompression of either digital audio or digital video. A codec can also refer to a device or software that implements the standard. Some examples of codecs include the following:

  • H.264 (ITU-T H.264 / ISO MPEG-4 AVC): A standard for video compression specified in the standard MPEG-4 Part 10.

  • AAC: A standard for audio compression specified in the standard MPEG-2 Part 7 and MPEG-4 Part 3 AAC.

  • VC-1 / WMV A family of video compression codecs initially developed by Microsoft. VC-1 is specified in the Society of Motion Pictures and Television Engineers (SMPTE) standard 421.

  • WMA: A family of audio compression codecs developed by Microsoft.

  • MP3: A standard for audio compression specified in MPEG-1 Part 3 and MPEG-2 Part 3. Also, a container format for the MP3 codec.

Delivering Content

In order to deliver content to users, a content distributer must first determine the following:

  • Codec: What codec will be used to encode the media samples? For example, possible codecs could be H264, AAC, or WMA.

  • Container: What format will the media samples be contained in? For example, ASF, MP4, or PIFF.

  • Delivery Technology: How will the media be delivered to users? For example, smooth streaming, traditional streaming, or progressive download.

A distributer might start with the following choices to ensure maximum compatibility across a wide range of devices:

  • H.264 and AAC for the video and audio codec respectively.

  • MP4 for the container format.

  • Support for progressive download.

The distributer might then later make the following changes:

  • Switch the container format to PIFF to protect the content from piracy.

  • Add support for smooth streaming, which will add the following benefits:

    • Let the user seek to any arbitrary point in the content (as with traditional streaming).

    • Ensure the user automatically gets the best resolution and bit rate that does not result in buffering delays. (For example, there is no need to select 480p, etc.)

Accessing Content

A Silverlight application (XAP) uses one of four techniques to programmatically access content:

1. The XAP sets MediaElement.Source to a Uniform Resource Identifier (URI)

In this case, Silverlight will do the following:

  • Determine the delivery technology from the URI.

  • Retrieve the media.

  • Determine the container format and the codecs it uses.

  • Parse the container for samples.

  • Decrypt and decode the samples.

This is the simplest of the four options. This can be done entirely in XAML and Silverlight does all the work. However, the delivery technology and the container format must be natively supported by Silverlight.

2. The XAP calls MediaElement.SetSource (System.IO.Stream overload).

In this case, the Stream object supplied by the XAP will do the following:

  • Retrieve the media.

  • Implement the delivery technology. For example, progressive download or traditional streaming.

Silverlight will then do the following:

  • Determine the container format and the codecs it uses.

  • Parse the container for samples.

  • Decrypt and decode the samples.

This option is used for playing back previously downloaded content, along with content not accessible through a standardized URI. The container format must be natively supported by Silverlight.

NoteNote:

In Silverlight for Windows Phone, this technique is only supported for the IsolatedStorageFileStream class.

3. The XAP calls SetSource (System.Windows.Media.MediaStreamSource overload)

In this case, the MediaStreamSource object supplied by the XAP will do the following:

  • Implement the delivery technology.

  • Retrieve the media.

  • Determine the container format and the codecs it uses.

  • Parse the media container for samples.

  • Inform Silverlight which parts of the samples are encrypted.

Silverlight will then do the following:

  • Decrypt and decode the samples.

    This option is used for containers and protocols that Silverlight does not natively support.

4. The XAP uses an alternative MediaElement implementation such as the SmoothStreamingMediaElement.

A replacement MediaElement class typically provides additional features not supported by the native MediaElement class such as ad insertion. The writers of replacement MediaElement classes typically build them on top of a native MediaElement and a MediaStreamSource class.

Supported Codecs

For a list of the audio and video codecs supported by Silverlight, see Supported Media Formats, Protocols, and Log Fields.

Supported Containers

For a list of the containers supported by Silverlight, see Supported Media Formats, Protocols, and Log Fields.

Supported Delivery Technologies

For a list of the delivery technologies supported by Silverlight, see Supported Media Formats, Protocols, and Log Fields.