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
 
Thread Tools Display Modes
Old 2006-07-27, 22:40   #1 (permalink)
Portal Member
 
Join Date: May 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts


Default Myscript: Catching event handler

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!
magnuje2 is offline   Reply With Quote
Reply

Bookmarks

Tags
catching, event, handler, 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 Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
catching TV on event opusnut Plugins 1 2006-11-02 19:12
Some random recordings stop recording ocram General Support 1 2006-10-18 11:11
Auto Resume After Suspend Procedure Dado The old Bugreport Forum 28 2006-04-23 18:59
My TV can tune in DVB-T & see event info but no A/V lshih Codecs, External Players 0 2006-04-03 20:56
Mediaportal crashing when power scheduler is activated Adrian2M General Support 0 2005-12-30 17:07


All times are GMT +1. The time now is 04:55.


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
Advertisement System V2.6 By   Branden