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)
Syntax
'Declaration
Public Interface ISmoothStreamingCache
'Usage
Dim instance As ISmoothStreamingCache
public interface ISmoothStreamingCache
public interface class ISmoothStreamingCache
type ISmoothStreamingCache = interface end
public interface ISmoothStreamingCache
The ISmoothStreamingCache type exposes the following members.
Methods
Name | Description | |
---|---|---|
BeginPersist | Begins 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. | |
BeginRetrieve | Begins an asynchronous cache response retrieval. | |
CloseMedia | Ends ISmoothStreamingCache operations for the specified media. | |
EndPersist | A AsyncCallback delegate method to complete the operation started by the BeginPersist method. | |
EndRetrieve | Ends an asynchronous cache response retrieval started by the BeginRetrieve method. | |
OpenMedia | Opens the specified media for ISmoothStreamingCache operations. |
Top
Remarks
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.
Examples
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.
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();
}
Warning
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.
Version Information
Silverlight
Supported in: 5
Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0