- January 24, 2012
- 2,569
- 2,680
- Home Country
- United Kingdom
- Thread starter
- Moderator
- #31
If i create a project and add your source code i getHi!
This look like fun, so I tried to do something simple. Adding the dll, and the property that is it use is : #ImagePlugin.Image
Place the plugin i process plugin folder. Changing picture every 20s. Needs a folder C:\ProgramData\Team MediaPortal\MediaPortal\ImagePlugin
Pasting source soon.[DOUBLEPOST=1420896086][/DOUBLEPOST]Ther is nothing random at all here, but that should be easy to fix. Place your images in the above mentioned folder ImagePlugin
Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.IO; using MediaPortal.GUI.Library; namespace ImagePlugin { public class ImagePlugin : IPlugin, ISetupForm { bool _directoryLoaded = false; private List<string> _fileList = new List<string>(); int _currentImage = 0; Timer timer; // Returns the author of the plugin which is shown in the plugin menu public string Author() { return "Ministerk"; } // Indicates whether plugin can be enabled/disabled public bool CanEnable() { return true; } // Indicates if plugin is enabled by default; public bool DefaultEnabled() { return true; } // Returns the description of the plugin is shown in the plugin menu public string Description() { return "Image"; } /// <summary> /// If the plugin should have it's own button on the main menu of MediaPortal then it /// should return true to this method, otherwise if it should not be on home /// it should return false /// </summary> /// <param name="strButtonText">text the button should have</param> /// <param name="strButtonImage">image for the button, or empty for default</param> /// <param name="strButtonImageFocus">image for the button, or empty for default</param> /// <param name="strPictureImage">subpicture for the button or empty for none</param> /// <returns>true : plugin needs it's own button on home /// false : plugin does not need it's own button on home</returns> public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) { strButtonText = PluginName(); strButtonImage = String.Empty; strButtonImageFocus = String.Empty; strPictureImage = String.Empty; return false; } // indicates if a plugin has it's own setup screen public bool HasSetup() { return false; } // Returns the name of the plugin which is shown in the plugin menu public string PluginName() { return "ImagePlugin"; } // show the setup dialog public void ShowPlugin() { } public int GetWindowId() { return 0; } void IPlugin.Start() { timer = new Timer(new TimerCallback(TimerProc)); timer.Change(1000, 20000); } void IPlugin.Stop() { timer.Dispose(); } private void TimerProc(object state) { if (GUIWindowManager.ActiveWindow > 0) { LoadDirectory(); if(_directoryLoaded && _fileList.Count > 0) { if (_currentImage >= _fileList.Count()) _currentImage = 0; GUIPropertyManager.SetProperty("#ImagePlugin.Image", _fileList[_currentImage]); Log.Debug("ImagePlugin change picture"); _currentImage++; } } } private void LoadDirectory() { if (_directoryLoaded) { return; } // Unload any images from our texture bundle first _fileList.Clear(); // Folder of images try { string imageFolder = MediaPortal.Configuration.Config.GetSubFolder(MediaPortal.Configuration.Config.Dir.Config, @"ImagePlugin"); // Try to use the provided folder as an absolute path if (!Directory.Exists(imageFolder)) return; // Load the image files string[] files = Directory.GetFiles(imageFolder); foreach (string file in files) { if (MediaPortal.Util.Utils.IsPicture(file)) { _fileList.Add(file); } } if (_fileList.Count() > 0) _directoryLoaded = true; } catch (UnauthorizedAccessException) { return; } catch (Exception) { return; } } } }
Error 1 The type or namespace name 'Config' does not exist in the namespace 'MediaPortal.Configuration' (are you missing an assembly reference?)