how to hook ISmoothStreamCache object in SMFPlayer (Smooth Streaming Development kit)

287 Views Asked by At

I am using SMFPlayer in SilverLight Smooth Streaming Development Kit. And I am able to play video content, however for some reason we want to have control over data being downloaded and parsed. For that Purpose we want to start using ISmoothStreamingCache interface. I want to know what is the right approach to hook ISmoothStreamingCache object in SMFPlayer.

Thanks in advance

Big O

1

There are 1 best solutions below

0
Kedar Vaidya On

The ISmoothStreamingCache's implementation should also implement IPlugin interface. It should also be decorated with ExportAdaptiveCacheProvider attribute.

Then it will be automatically hooked to the SMFPlayer.

Below is skeleton code for class:

using System;
using System.Collections.Generic;
using System.IO.IsolatedStorage;
using System.Net;
using Microsoft.SilverlightMediaFramework.Plugins;
using Microsoft.SilverlightMediaFramework.Plugins.Metadata;
using Microsoft.Web.Media.SmoothStreaming;

namespace MyNamespace
{
    [ExportAdaptiveCacheProvider(PluginName = "My Smooth Streaming Cache")]
    public class MySmoothStreamingCache : ISmoothStreamingCache, IPlugin
    {
        public MySmoothStreamingCache()
        {
            // Your implementation
        }

        #region ISmoothStreamingCache members
        public IAsyncResult BeginRetrieve(CacheRequest request, AsyncCallback callback, object state)
        {
            // Your implementation
        }

        public CacheResponse EndRetrieve(IAsyncResult ar)
        {
            // Your implementation
        }

        public IAsyncResult BeginPersist(CacheRequest request, CacheResponse response, AsyncCallback callback, object state)
        {
            // Your implementation
        }

        public bool EndPersist(IAsyncResult ar)
        {
            // Your implementation
        }

        public void OpenMedia(Uri manifestUri)
        {
            // Your implementation
        }

        public void CloseMedia(Uri manifestUri)
        {
            // Your implementation
        }
        #endregion

        #region IPlugin members
        public bool IsLoaded { get; private set; }

        public void Load()
        {
            IsLoaded = true;
        }

        public event Action<IPlugin, Microsoft.SilverlightMediaFramework.Plugins.Primitives.LogEntry> LogReady;

        public event Action<IPlugin, Exception> PluginLoadFailed;

        public event Action<IPlugin> PluginLoaded;

        public event Action<IPlugin, Exception> PluginUnloadFailed;

        public event Action<IPlugin> PluginUnloaded;

        public void Unload()
        {
            IsLoaded = false;
        }
        #endregion
    }
}