Myscript: Catching event handler (1 Viewer)

magnuje2

Portal Member
May 11, 2006
23
0
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!
 

Users who are viewing this thread

Top Bottom