MediaPortal Forums HTPC/MediaCenter

Go Back   MediaPortal Forum » MediaPortal 1 » Community Skins and Plugins » Plugins


Plugins Plugins developed and maintained by users. Want to create your own plugin? Start a thread in here.

Reply
 
LinkBack Thread Tools Display Modes
Old 2005-09-07, 18:34   #1 (permalink)
Portal Member
 
Clodo's Avatar
 
Join Date: Jul 2005
Location: Milan, Italy
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts


Default MyScript

Plugin Name:MyScript
Current Version/State:1.0 (20/06/2006).
Download : http://www.itazz.net/files/Clodo/Med...l/MyScript.zip
Source : http://www.itazz.net/files/Clodo/Med...Script_src.zip
Description: C# "script" without need to build the sources.
Screenshot:




Can be useful to add some custom code (cool stuffs, for automatization, for patch, for debug) without the MP sources.
Install Instructions : Extract the zip file to the MAIN MediaPortal directory.

The development of this plugin is started from this discussion thread:
http://nolanparty.com/mediaportal.so...623&highlight=

Please discuss here about plugin problems, and in the topic above for the
"conceptional/design level" around the plugin.

Press 'Ctrl+S' inside MP to show the Scripts Manager.

Enjoy!
Clodo is offline   Reply With Quote
Old 2005-09-26, 11:18   #2 (permalink)
Portal Member
 
Clodo's Avatar
 
Join Date: Jul 2005
Location: Milan, Italy
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts


Default

I'm start to writing a new version with a script manager inside configuration, for every script opyion like language (c# or VB), compiling options, Scintilla text editor, autostart (none,config,application,both), start/stop method inside script to allow connection/deconnection to MP events, store all scripts data inside an xml file (there is also an option for storing the code externally, for debugging purpose), more compiler error feedback, etc.. etc..

But i don't read any feedback, nobody think that can be useful?

Bye! Clodo
Clodo is offline   Reply With Quote
Old 2005-09-26, 11:41   #3 (permalink)
Portal Member
 
Smirnuff's Avatar
 
Join Date: Dec 2004
Location: United Kingdom
Posts: 630
Thanks: 0
Thanked 2 Times in 1 Post

My System

Default

My thoughts on this are that Python (or more specifically IronPython) would make a better scripting language for MP, the main reason being that its the easiest language for a beginner to use and subsequently would be of more use to your average MP user. Either way, the scripting concept should be the same so scripting in .NET languages is still a nice idea.

I also think it will receive more attention if you were to give a couple of real world examples of how this can be used and perhaps come up with a list of useful events that we can add to the application that will make it possible to do much more within a script.

I almost forgot, we are doing a huge amount of work on the skinning engine, so in the future such nice keyboard designs as the one you previously presented will be far easier to code, but the point here is that its going to be based on XAML/Avalon and perhaps you could take a look at how M$ are implementing their automation layer within XAML, would be mighty cool...

Cheers,
Smirnoff.
Smirnuff is offline   Reply With Quote
Old 2005-09-26, 12:04   #4 (permalink)
Portal Member
 
Clodo's Avatar
 
Join Date: Jul 2005
Location: Milan, Italy
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts


Default

Hi smirnoff, i don't know anything about the integration of Python or IronPython, but probably require a modification in the core, and many wrapper to c# code, right? If people create a process plugin without knowing that exists the script engine, and declare an event, the event can be directly used by MyScriptC#.

So, as explained in the 'conceptional' thread here, if every script it's derived from a IScript base class, that offer different useful methods and events, can be very useful not only for developer, but also for a beginner.

I try to include some better examples in the next release, but i write this post also for feedback about examples that can be useful...

For example, a script that link the PerformanceCounter on a variable in GuiProperty, that allow people to write a custom 'System Info' gui window, can be useful?

thanks for reply! bye!
Clodo is offline   Reply With Quote
Old 2005-09-26, 12:55   #5 (permalink)
Portal Member
 
Clodo's Avatar
 
Join Date: Jul 2005
Location: Milan, Italy
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts


Default

About XAML/Avalon, it's very cool, but i have too much ideas open, and i want to finish at least one, in this case the script engine, before continue on another idea (my keyboard), that is not useful to many users that don't have an analog stick...
Clodo is offline   Reply With Quote
Old 2005-09-26, 12:58   #6 (permalink)
Portal Member
 
Smirnuff's Avatar
 
Join Date: Dec 2004
Location: United Kingdom
Posts: 630
Thanks: 0
Thanked 2 Times in 1 Post

My System

Default

Quote:
but i have too much ideas open
I know exactly what you mean.

Quote:
that allow people to write a custom 'System Info' gui window, can be useful?
Yeah that would be a good one, anything that gets people thinking about what they can do will see this thread come alive.
Smirnuff is offline   Reply With Quote
Old 2005-09-26, 15:06   #7 (permalink)
Retired Team Member
 
mzemina's Avatar
 
Join Date: Feb 2005
Location: Ft Smith, AR
Posts: 2,029
Thanks: 33
Thanked 12 Times in 12 Posts

Country:


Default

Who is going to record and publish a help file so that this plugin can be used with all the MP events? Without that, this plugin really won't be used by many people and then will be dropped because of a lack of use.

Mike
mzemina is online now   Reply With Quote
Old 2005-09-29, 00:10   #8 (permalink)
Portal Member
 
Clodo's Avatar
 
Join Date: Jul 2005
Location: Milan, Italy
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts


Default

here exists a thread about a CHM documentation file that can be useful to find events, allow people to write a script without need to browse the sources.... (really? imho, too much difficult....)

open chm > search tab > check the check box 'search only in title', and use "events" as searching string.

bye!.
Clodo is offline   Reply With Quote
Old 2005-10-21, 11:42   #9 (permalink)
Portal Member
 
Clodo's Avatar
 
Join Date: Jul 2005
Location: Milan, Italy
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts


Default

I have updated the first post with a new release.

There are some little-fix that i need to do, but works.
Support C#, VB.NET and JScript, but for the moment i test only C#.

Two sample scripts are in plugins\process\myscript

Please feedback any suggestions/bug report!

We need help on some things, read the 'Help' tab in Scripts Manager, thanks!

enjoy!
Clodo is offline   Reply With Quote
Old 2005-10-22, 18:35   #10 (permalink)
Portal Member
 
Clodo's Avatar
 
Join Date: Jul 2005
Location: Milan, Italy
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts


Default

The question: Can be python (or lua, or ecma-script, or...) can be added to this plugins?

MP & community plugins are compiled in .NET assembly, in a language called CLR (Common Language Runtime).
See http://www.gotdotnet.com/team/clr/about_clr.aspx


MyScript uses .NET reflection to compile the script in a .NET assembly, and for this reason only language that can be compiled in CLR
(C#, VB.NET and JScript) are currenly supported.

This allow people to write script that interact with MP or other plugins, without need to change the MP core, and without need that others plugins authors know the
existence of MyScript or the language that MyScript support.

I have some esperience about integration of Python,Lua and java-script in C++ code, but every solutions require to create many wrapper class that create a 'link'
between the C++ internal code and the script.

Adding a language script that are not compiled in CLR (so, don't use reflection) need creations of class wrapper around all features in MP core that need to be exposed to script language, and is a very very big works.
Also, people that write plugin need also to create this kind of wrapper to allow people to write script that interact with the plugin.


To understand, this is a piece of code inside \WindowPlugins\GUIScript\MPScript.cs, the actual MyScript included in MP distributions:

Code:
	private void callAction(string ac)
		{
			Action act;
			switch (ac)
			{
				case "reboot" :
					act = new Action(Action.ActionType.ACTION_REBOOT,0,0);
					GUIGraphicsContext.OnAction(act);
					break;
				case "shutdown" :
					act = new Action(Action.ActionType.ACTION_SHUTDOWN,0,0);
					GUIGraphicsContext.OnAction(act);
					break;
				case "hibernate" :
					WindowsController.ExitWindows(RestartOptions.Hibernate, m_bForceShutdown);
					break;
				case "ejectcd" :
					act = new Action(Action.ActionType.ACTION_EJECTCD,0,0);
					GUIGraphicsContext.OnAction(act);
					break;
				case "previous_menu" :
					act = new Action(Action.ActionType.ACTION_PREVIOUS_MENU,0,0);
					GUIGraphicsContext.OnAction(act);
					break;
			}
		}
As explained, the author need to create wrapper between script and MP core.



My question is: Why people want Python? C# Script allow people to write any kind of code.
The only problem is the complexity to write a script, for that i suggest
to create the Main class in script derived from 'Script', and add some simply methods in this class (like the 'MessageBox' or 'Trace' method already present).



Another example,

I found a topic called "Text to Speech.......Make MediaPortal Talk" here.

To allow that, can simple write a 'script' like:

Code:
using System;
using System.Windows.Forms;
using MediaPortal.GUI.Library;
using MediaPortal.Dialogs;
using MyScript;
using SpeechLib;

class Main : Script
{
	public void Start()
	{
			Say("Mediaportal starts!!");
	}

	public void Stop()
	{
	}

	public void Say(string input)
	{
		SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync;
		SpVoice Voice = new SpVoice();
		Voice.Speak(input,SpFlags);
	}
}
, and copy the dll Interop.SpeechLib.dll in MP directory.

(N.B. it's not actually possible to write this script, because in this current release we cannot add additional external assembly reference, but can be possible in the next release).

With another language not-CLR like Python, we need to create a class wrapper between Interop.SpeechLib.dll and Python.



--------------------------


I'm looking on IronPython, suggested by Smirnoff.
Can be possible to write Python scripts that use CLR-based assembly, but, if i understand correctly, the script itself is not compiled in CLR.

It's not derived from ICodeCompiler , so don't allow code compiling over reflection....

In contrast of all texts written above, i can try to integrate to check how it works....
I don't know the python syntax, but i don't think that python language can be more simple to write than a C# or VB.NET script (with a good 'Script' base class)

Bye!
Clodo is offline   Reply With Quote
Reply

Bookmarks

Tags
myscript

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Myscript: Catching event handler magnuje2 Plugins 0 2006-07-27 21:40
An idea about interoperability and scripting... Clodo General Development (no feature request here!) 5 2005-09-26 11:19


All times are GMT +1. The time now is 23:59.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 Protected by Akismet Blog with WordPress