本文整理汇总了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.");
}