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
MediaPortal 1 Plugins
Myscript: Catching event handler
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="magnuje2" data-source="post: 67251" data-attributes="member: 20493"><p>Hi, i have a (myscript) script i use for turning on and off my amp when media is played/ended, but with the latest release it seems there have been some changes in MyTV, so now my amp goes off and on again every time i change channel... </p><p></p><p>So, a workaround would be to catch a standby event from Mediaportal and keep my amp on until then. But i havent found the right event handler in the MSDN. Any suggestions?</p><p></p><p>An alternative solution would be some kind of timer that would send an event (found this in the MSDN but not sure how to do this) and then check if media is playing or not and then do the right actions.</p><p></p><p>Here's my code without the amp off part:</p><p></p><p><xml></p><p><MyScript></p><p> <This></p><p> <Name>Amplifier</Name></p><p> <Description>Turns on the amp when needed</Description></p><p> <Author>Magnus</Author></p><p> <Version>1</Version></p><p> <Code>using System;</p><p>using System.Diagnostics;</p><p>using System.Windows.Forms;</p><p>using MediaPortal.MyScript;</p><p>using MediaPortal.GUI.Library;</p><p>using MediaPortal.Dialogs;</p><p>using MyScript;</p><p>using MediaPortal.Player;</p><p>using System.Threading;</p><p></p><p></p><p></p><p>class Main : Script</p><p>{ </p><p></p><p> </p><p> public void Start() </p><p> {</p><p> g_Player.PlayBackStarted += new g_Player.StartedHandler(Started);</p><p> </p><p> }</p><p> </p><p> public void Stop() </p><p> { </p><p> g_Player.PlayBackStarted -= new g_Player.StartedHandler(Started);</p><p> }</p><p> </p><p> private void Started(g_Player.MediaType type, string filename)</p><p> {</p><p> </p><p> Process p=null;</p><p> try</p><p> {</p><p> string targetDir;</p><p> targetDir = string.Format(@"C:\IR");</p><p> p= new Process();</p><p> p.StartInfo.WorkingDirectory = targetDir;</p><p> p.StartInfo.FileName = "on.bat";</p><p></p><p> p.StartInfo.Arguments = string.Format("Console application");</p><p> p.StartInfo.CreateNoWindow = true;</p><p> p.Start();</p><p> p.WaitForExit();</p><p> } </p><p> catch (Exception ex)</p><p> {</p><p> Console.WriteLine("Exception Occurred :{0},{1}", </p><p> ex.Message,ex.StackTrace.ToString());</p><p> } </p><p> </p><p> }</p><p></p><p>}</Code></p><p> <ExternalCodeFile></p><p> <Language>C#</Language></p><p> <AutoStart>Application</AutoStart></p><p> <WarningLevel>4</WarningLevel></p><p> <TreatWarningsAsErrors>False</TreatWarningsAsErrors></p><p> <IncludeDebugInformation>False</IncludeDebugInformation></p><p> <AdditionalAssemblies></p><p></MyScript></p><p></p><p>I hope i get this working again, it worked so sweet in the previous releases : ) I don't know C# very well so please explain the implimentation if you have a solution!</p><p></p><p>thanks!</p></blockquote><p></p>
[QUOTE="magnuje2, post: 67251, member: 20493"] Hi, i have a (myscript) script i use for turning on and off my amp when media is played/ended, but with the latest release it seems there have been some changes in MyTV, so now my amp goes off and on again every time i change channel... So, a workaround would be to catch a standby event from Mediaportal and keep my amp on until then. But i havent found the right event handler in the MSDN. Any suggestions? An alternative solution would be some kind of timer that would send an event (found this in the MSDN but not sure how to do this) and then check if media is playing or not and then do the right actions. Here's my code without the amp off part: <xml> <MyScript> <This> <Name>Amplifier</Name> <Description>Turns on the amp when needed</Description> <Author>Magnus</Author> <Version>1</Version> <Code>using System; using System.Diagnostics; using System.Windows.Forms; using MediaPortal.MyScript; using MediaPortal.GUI.Library; using MediaPortal.Dialogs; using MyScript; using MediaPortal.Player; using System.Threading; class Main : Script { public void Start() { g_Player.PlayBackStarted += new g_Player.StartedHandler(Started); } public void Stop() { g_Player.PlayBackStarted -= new g_Player.StartedHandler(Started); } private void Started(g_Player.MediaType type, string filename) { Process p=null; try { string targetDir; targetDir = string.Format(@"C:\IR"); p= new Process(); p.StartInfo.WorkingDirectory = targetDir; p.StartInfo.FileName = "on.bat"; p.StartInfo.Arguments = string.Format("Console application"); p.StartInfo.CreateNoWindow = true; p.Start(); p.WaitForExit(); } catch (Exception ex) { Console.WriteLine("Exception Occurred :{0},{1}", ex.Message,ex.StackTrace.ToString()); } } }</Code> <ExternalCodeFile> <Language>C#</Language> <AutoStart>Application</AutoStart> <WarningLevel>4</WarningLevel> <TreatWarningsAsErrors>False</TreatWarningsAsErrors> <IncludeDebugInformation>False</IncludeDebugInformation> <AdditionalAssemblies> </MyScript> I hope i get this working again, it worked so sweet in the previous releases : ) I don't know C# very well so please explain the implimentation if you have a solution! thanks! [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
MediaPortal 1 Plugins
Myscript: Catching event handler
Contact us
RSS
Top
Bottom