当前位置: 首页>>代码示例>>C#>>正文


C# Kernel.AddExternalPlayableItem方法代码示例

本文整理汇总了C#中Kernel.AddExternalPlayableItem方法的典型用法代码示例。如果您正苦于以下问题:C# Kernel.AddExternalPlayableItem方法的具体用法?C# Kernel.AddExternalPlayableItem怎么用?C# Kernel.AddExternalPlayableItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kernel的用法示例。


在下文中一共展示了Kernel.AddExternalPlayableItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        public override void Init(Kernel kernel)
        {
            PluginOptions = new PluginConfiguration<PluginOptions>(kernel, this.GetType().Assembly);
            PluginOptions.Load();

            var trailers = (kernel.ItemRepository.RetrieveItem(TrailersGuid) as MBTrailerFolder) ?? new MBTrailerFolder();
            trailers.Path = "";
            trailers.Id = TrailersGuid;
            //validate sort value and fill in
            //int sort = 0;
            //int.TryParse(PluginOptions.Instance.SortOrder, out sort);
            //if (sort > 0) trailers.SortName = sort.ToString("000");
            //Logger.ReportInfo("MBTrailers Sort is: " + trailers.SortName);

            kernel.RootFolder.AddVirtualChild(trailers);

            if (Kernel.LoadContext == MBLoadContext.Service || Kernel.LoadContext == MBLoadContext.Core)  //create proxy in core and service (will only listen in service)
            {
                string cachePath = PluginOptions.Instance.CacheDir;
                if (string.IsNullOrEmpty(cachePath) || !System.IO.Directory.Exists(cachePath))
                {
                    cachePath = System.IO.Path.Combine(ApplicationPaths.AppConfigPath, "TrailerCache");
                    if (!Directory.Exists(cachePath))
                    {
                        Directory.CreateDirectory(cachePath);
                    }
                }

                long maxBandwidth = 1000 * 1024;
                long.TryParse(PluginOptions.Instance.MaxBandWidth, out maxBandwidth);
                if (maxBandwidth < 0)
                    maxBandwidth = 1000 * 1024;
                else
                    maxBandwidth = maxBandwidth * 1024L;

                proxy = new HttpProxy(cachePath, ProxyPort);
                if (Kernel.LoadContext == MBLoadContext.Service)
                { //only actually start the proxy in the service
                    Logger.ReportInfo("MBTrailers starting proxy server on port: " + ProxyPort);
                    proxy.Start(PluginOptions.Instance.AutoDownload, maxBandwidth);
                    //and clean up the cache if requested
                    if (PluginOptions.Instance.AutoClearCache)
                    {
                        MediaBrowser.Library.Threading.Async.Queue("MBTrailers cache clear", () =>
                        {
                             while (true)
                             {
                                 trailers.CleanCache();
                                 System.Threading.Thread.Sleep(24 * 60 * 60000); //once per day
                             }

                        });
                    }
                }
                else
                {
                    if (proxy.AlreadyRunning())
                        Logger.ReportInfo("MBTrailers not starting proxy.  Running in service.");
                    else
                        Logger.ReportInfo("MBTrailers - no proxy running.  Start Media Browser Service.");
                }
                //load mytrailers option if specified
                if (PluginOptions.Instance.ShowMyTrailers)
                {
                    localTrailers = kernel.ItemRepository.RetrieveItem(MyTrailersGuid) as LocalTrailerFolder ?? new LocalTrailerFolder();
                    localTrailers.Id = MyTrailersGuid;
                    kernel.RootFolder.AddVirtualChild(localTrailers);
                    kernel.ItemRepository.SaveItem(localTrailers);

                    //make sure our image cache is there
                    if (!Directory.Exists(Util.ImageCache))
                        try
                        {
                            Directory.CreateDirectory(Util.ImageCache);
                        }
                        catch (Exception e)
                        {
                            Logger.ReportException("Error Creating MyTrailers Image Cache: " + Util.ImageCache, e);
                        }

                    //Tell the log we loaded.
                    Logger.ReportInfo("My Trailers Support Loaded.");
                }

                //refresh the paths of trailers, but wait a bit in case the service side isn't up yet (we load before the service)
                MediaBrowser.Library.Threading.Async.Queue("MB Trailers refresh",() => trailers.RefreshProxy(), 3000);

                //tell core our types are playable (for menus)
                kernel.AddExternalPlayableItem(typeof(ITunesTrailer));
                kernel.AddExternalPlayableFolder(typeof(MBTrailerFolder));
            }
            Logger.ReportInfo("MBTrailers (version "+Version+") Plug-in loaded.");
        }
开发者ID:xantilas,项目名称:videobrowser,代码行数:93,代码来源:Plugin.cs


注:本文中的Kernel.AddExternalPlayableItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。