home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
General Development (no feature request here!)
A little help ?
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Ministerk" data-source="post: 1119220" data-attributes="member: 61145"><p>Hi!</p><p>This look like fun, so I tried to do something simple. Adding the dll, and the property that is it use is : #ImagePlugin.Image</p><p></p><p>Place the plugin i process plugin folder. Changing picture every 20s. Needs a folder C:\ProgramData\Team MediaPortal\MediaPortal\ImagePlugin</p><p></p><p>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</p><p></p><p></p><p>[CODE=C#]using System;</p><p>using System.Collections.Generic;</p><p>using System.Linq;</p><p>using System.Text;</p><p>using System.Threading;</p><p>using System.IO;</p><p>using MediaPortal.GUI.Library;</p><p></p><p>namespace ImagePlugin</p><p>{</p><p> public class ImagePlugin : IPlugin, ISetupForm</p><p> {</p><p> bool _directoryLoaded = false;</p><p> private List<string> _fileList = new List<string>();</p><p> int _currentImage = 0;</p><p> Timer timer;</p><p></p><p> // Returns the author of the plugin which is shown in the plugin menu</p><p> public string Author()</p><p> {</p><p> return "Ministerk";</p><p> }</p><p></p><p> // Indicates whether plugin can be enabled/disabled</p><p> public bool CanEnable()</p><p> {</p><p> return true;</p><p> }</p><p></p><p> // Indicates if plugin is enabled by default;</p><p> public bool DefaultEnabled()</p><p> {</p><p> return true;</p><p> }</p><p></p><p> // Returns the description of the plugin is shown in the plugin menu</p><p> public string Description()</p><p> {</p><p> return "Image";</p><p> }</p><p></p><p> /// <summary></p><p> /// If the plugin should have it's own button on the main menu of MediaPortal then it</p><p> /// should return true to this method, otherwise if it should not be on home</p><p> /// it should return false</p><p> /// </summary></p><p> /// <param name="strButtonText">text the button should have</param></p><p> /// <param name="strButtonImage">image for the button, or empty for default</param></p><p> /// <param name="strButtonImageFocus">image for the button, or empty for default</param></p><p> /// <param name="strPictureImage">subpicture for the button or empty for none</param></p><p> /// <returns>true : plugin needs it's own button on home</p><p> /// false : plugin does not need it's own button on home</returns></p><p></p><p> public bool GetHome(out string strButtonText, out string strButtonImage,</p><p> out string strButtonImageFocus, out string strPictureImage)</p><p> {</p><p> strButtonText = PluginName();</p><p> strButtonImage = String.Empty;</p><p> strButtonImageFocus = String.Empty;</p><p> strPictureImage = String.Empty;</p><p> return false;</p><p> }</p><p></p><p> // indicates if a plugin has it's own setup screen</p><p> public bool HasSetup()</p><p> {</p><p> return false;</p><p> }</p><p></p><p> // Returns the name of the plugin which is shown in the plugin menu</p><p> public string PluginName()</p><p> {</p><p> return "ImagePlugin";</p><p> }</p><p></p><p> // show the setup dialog</p><p> public void ShowPlugin()</p><p> {</p><p></p><p> }</p><p></p><p> public int GetWindowId()</p><p> { return 0; }</p><p></p><p> void IPlugin.Start()</p><p> {</p><p> timer = new Timer(new TimerCallback(TimerProc));</p><p> timer.Change(1000, 20000);</p><p> }</p><p></p><p> void IPlugin.Stop()</p><p> {</p><p> timer.Dispose();</p><p> }</p><p></p><p> private void TimerProc(object state)</p><p> {</p><p> if (GUIWindowManager.ActiveWindow > 0)</p><p> {</p><p> LoadDirectory();</p><p> if(_directoryLoaded && _fileList.Count > 0)</p><p> {</p><p> if (_currentImage >= _fileList.Count())</p><p> _currentImage = 0;</p><p> GUIPropertyManager.SetProperty("#ImagePlugin.Image", _fileList[_currentImage]);</p><p> Log.Debug("ImagePlugin change picture");</p><p></p><p> _currentImage++;</p><p> }</p><p> }</p><p> }</p><p></p><p> private void LoadDirectory()</p><p> {</p><p> if (_directoryLoaded)</p><p> {</p><p> return;</p><p> }</p><p></p><p> // Unload any images from our texture bundle first</p><p> _fileList.Clear();</p><p></p><p> // Folder of images</p><p> try</p><p> {</p><p> string imageFolder = MediaPortal.Configuration.Config.GetSubFolder(MediaPortal.Configuration.Config.Dir.Config, @"ImagePlugin");</p><p> // Try to use the provided folder as an absolute path</p><p> if (!Directory.Exists(imageFolder))</p><p> return;</p><p> // Load the image files</p><p> string[] files = Directory.GetFiles(imageFolder);</p><p> foreach (string file in files)</p><p> {</p><p> if (MediaPortal.Util.Utils.IsPicture(file))</p><p> {</p><p> _fileList.Add(file);</p><p> }</p><p> }</p><p> if (_fileList.Count() > 0)</p><p> _directoryLoaded = true;</p><p> }</p><p> catch (UnauthorizedAccessException)</p><p> {</p><p> return;</p><p> }</p><p> catch (Exception)</p><p> {</p><p> return;</p><p> }</p><p> }</p><p></p><p></p><p> }</p><p>}</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="Ministerk, post: 1119220, member: 61145"] Hi! 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=C#]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; } } } } [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
General Development (no feature request here!)
A little help ?
Contact us
RSS
Top
Bottom