1

我在 SilverLight Smooth Streaming Development Kit 中使用 SMFPlayer。而且我可以播放视频内容,但是出于某种原因,我们希望控制正在下载和解析的数据。为此,我们要开始使用 ISmoothStreamingCache 接口。我想知道在 SMFPlayer 中挂钩 ISmoothStreamingCache 对象的正确方法是什么。

提前致谢

大O

4

1 回答 1

0

ISmoothStreamingCache's实现也应该实现IPlugin接口。它也应该用ExportAdaptiveCacheProvider属性装饰。

然后它会自动挂接到 SMFPlayer。

下面是类的骨架代码:

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
    }
}
于 2013-04-17T08:35:47.177 回答