ISmoothStreamingCache Interface

Interface definition for writing a cache plug-in.

Namespace:  Microsoft.Web.Media.SmoothStreaming
Assembly:  Microsoft.Web.Media.SmoothStreaming (in Microsoft.Web.Media.SmoothStreaming.dll)

Public Interface ISmoothStreamingCache
Dim instance As ISmoothStreamingCache

The ISmoothStreamingCache type exposes the following members.

Public methodSupported by Silverlight for Windows PhoneBeginPersistBegins to persist a cache response. This function is called whenever in the course of normal playback a Smooth Streaming object chunk, manifest, or key frame is received from the network and it might be useful to persist the item for later use.
Public methodSupported by Silverlight for Windows PhoneBeginRetrieveBegins an asynchronous cache response retrieval.
Public methodSupported by Silverlight for Windows PhoneEndPersistA AsyncCallback delegate method to complete the operation started by the BeginPersist method.
Public methodSupported by Silverlight for Windows PhoneEndRetrieveEnds an asynchronous cache response retrieval started by the BeginRetrieve method.

The ISmoothStreamingCache interface supports offline playback scenarios. When the SmoothStreamingMediaElement needs a chunk or manifest, it first checks with the registered cache plug-in. If the plug-in has it, the chunk is used. Otherwise, the SmoothStreamingMediaElement downloads it by HTTP. After the download, SmoothStreamingMediaElement provides an option for the plug-in to persist the downloaded chunk.

The cache implementation is independent of any particular codec requirements. The SmoothStreamingMediaElement makes the same requests of the cache provider that it would over the wire to the server. A cache implementation can have a downloader that reads the client manifest and mimics the SmoothStreamingMediaElement by making requests to the server and storing the responses on the disk. When the SmoothStreamingMediaElement makes requests to the cache implementation, the cache provider replies with the pre-downloaded response now serialized to the disk.

You can assign a cache plug-in that implements ISmoothStreamingCache to the SmoothStreamingCache property of the SmoothStreamingMediaElement. Every time the SmoothStreamingMediaElement downloads a manifest or data chunk, the plug-in calls BeginRetrieve(CacheRequest, AsyncCallback, Object) or BeginPersist(CacheRequest, CacheResponse, AsyncCallback, Object) to provide an option to use cache data instead of downloading from the network or to save the data for future use.

A Silverlight IIS Smooth Streaming Offline Cache Sample that demonstrates implementation of ISmoothStreamingCache is available on the IIS Website.

For documentation of the sample, see Cache Plug-in Implementation of ISmoothStreamingCache.

The following example assigns the cache plug-in when the media element loads.

    private void SmoothPlayer_Loaded(object sender, RoutedEventArgs e)
        SmoothPlayer.SmoothStreamingCache = new SmoothStreaming.SmoothStreamingOfflineCache();

Caution noteCaution:

Do not set SSME.SmoothStreamingSource to a Uri that contains a query, such as http://domain/MultiAudio.ism/Manifest?foo=axjrjrn1.If this query is set and config.xml includes ResponseCacheEnabled="true" instead of ResponseCacheEnabled="false", the whole Uri including the query could be persisted in the response cache.


Supported in: 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.0