Event not firing (1 Viewer)

A

Anonymous

Guest
I'm working on integrating WinLIRC control of an external tuner.

I am implementing the funtionality in a similar way to USBUIRC.

I can't figure out why an event listener does not fire. Can anyone shed any light on this???? If USBUIRC is working, I can't figure out why this code does not work. I put some debug messages into the log, and I verify that the code that sends the message works, but the debug message in the recieve section of the code does not ever print to the log. Any ideas???? Thx...

This is the message being sent:.GUI_MSG_TUNE_EXTERNAL_CHANNEL

In recorder.cs, the message is sent:

static void TuneExternalChannel(string strChannelName, TVCaptureDevice theDev)
{
foreach (TVChannel chan in m_TVChannels)
{
if (chan.Name.Equals(strChannelName))
{
if (chan.External)
{
GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_TUNE_EXTERNAL_CHANNEL,0,0,0,0,0,null);
msg.Label=chan.ExternalTunerChannel;
msg.Label2 = theDev.FriendlyName;
GUIWindowManager.SendThreadMessage(msg);
Log.Write("********Sent message to tune external");
}
return;
}
}
}


In MediaPortal.cs, the message is listened to:

private void OnMessage(GUIMessage message)
{
switch (message.Message)
{
case GUIMessage.MessageType.GUI_MSG_CD_INSERTED:
AutoPlay.ExamineCD(message.Label);
break;

case GUIMessage.MessageType.GUI_MSG_SHOW_WARNING:
{
string strHead=GUILocalizeStrings.Get(message.Param1);
string strLine1=GUILocalizeStrings.Get(message.Param2);
string strLine2=GUILocalizeStrings.Get(message.Param3);
ShowInfo(strHead,strLine1,strLine2);
}
break;
case GUIMessage.MessageType.GUI_MSG_TUNE_EXTERNAL_CHANNEL :
Log.Write("*************Received Message to change external channel");
try...
 
A

Anonymous

Guest
Hi bobbo,

In order to receive the message you need to register the event to be fired.
If your class extends the "GUIWindow" class this is already done and your OnMessage should work.
public class MyClass: GUIWindow, IPlugin, ISetupForm

In case your class is not a GUIWindow you need to register the event yourself. Something like this.
using MediaPortal.GUI.Library;


Public MyClass()
{
GUIWindowManager.Receivers += new SendMessageHandler(MyOnMessage);
}

Public void MyOnMessage(GUIMessage message)
{
Switch etc...
}

Good luck,
 
A

Anonymous

Guest
Hey, thanks a lot. I will try this, I hope that this is it. The thing that I find funny is that I am not really adding in the sending or receiving code for this message. It was already there for USBUIRT. I would have thaought that everything would be set up properly and working already. Maybe it was at one point and it broke???

Thanks again
 
A

Anonymous

Guest
Damn, there was already code in the constructor to register the event handler.

The code in the constructor looks ok to me, but there is also a log entru written, LogWrite("Starting") that I never really see in the log.. I doubt if this code actually ever runs, but I am not sure why it wouldn't. It is in the constuctor of what I think is the main application class.

Here is the code from the constructor:

Log.Write("-------------------------------------------------------------------------------");
Log.Write("starting");
GUIGraphicsContext.form = this;
GUIGraphicsContext.graphics = null;
GUIGraphicsContext.ActionHandlers += new OnActionHandler(this.OnAction);
 
A

Anonymous

Guest
Actually, the code was a little futher down, still in the constructor of the MediaPortalApp constructor. But my comment above still applies. The code is there, but I don't see the logs that indicate that this code has ever executed.



GUIWindowManager.Receivers += new SendMessageHandler(OnMessage);
GUIWindowManager.Callbacks += new GUIWindowManager.OnCallBackHandler(this.Process);
GUIGraphicsContext.CurrentState = GUIGraphicsContext.State.STARTING;
 
A

Anonymous

Guest
I notice that some of the other OnMessage methods have a return type of bool, and are public. In MediaPortal.cs, the return type is void and it is set to private. Should any of this matter? I'm tempted to change it and try, but each time I try something, it takes me quite a while to build the app and transfer it to my other machine with the capture card for testing.
 
A

Anonymous

Guest
please ignore my last message, apparently the OnMessage method must have a null return type
 
A

Anonymous

Guest
Hey fred, I still haven't figured this out. From what I can see, everything should work. If you have any other ideas, please let me know.
 

Users who are viewing this thread

Top Bottom