Plugin for MulticastTV - IPTV client app

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
thehijacker
Posts: 7
Joined: Mon Jun 01, 2009 11:39 am

Plugin for MulticastTV - IPTV client app

Post by thehijacker » Mon Jun 01, 2009 11:48 am

I've been using this app for some time and I'd love to make it work with my remote control and IgorPlug USB IR device that I've built.

Before I even start studying how to build a plugin for it can someone please check if that is even possible.

URL to the software is:

http://sites.google.com/site/multicasttv/downloads

The author of the app also posted POST message code for it:
# POST (message, wparam, lparam)


1 POST(34952,1,0)
2 POST(34592,2,0)
3 POST(34952,3,0)
4 POST(34952,4,0)
5 POST(34952,5,0)
6 POST(34952,6,0)
7 POST(34952,7,0)
8 POST(34952,8,0)
9 POST(34952,9,0)
0 POST(34952,0,0)
Volume Down POST(34952,11,0)
Volume Up POST(34952,12,0)
Channel Up POST(34952,13,0)
Channel Down POST(34952,14,0)
Record POST(34952,15,0)
Back POST(34952,16,0)
OSD Channel POST(34952,18,0)
Full Screen POST(34952,19,0)
Table POST(34952,20,0)
Mute POST(34952,21,0)
Pause POST(34952,22,0)
Play Faster POST(34952,23,0)
Play Slower POST(34952,24,0)
Snapshot POST(34952,25,0)
Recall POST(34952,26,0)
Aspect Ratio POST(34952,27,0)
Crop POST(34952,28,0)
Left POST(34592,102,0)
Right POST(34592,103,0)
Up POST(34592,100,0)
Down POST(34592,101,0)
PIP POST(34592,29,0)
Epg scroll up POST(34592,30,0)
Epg scroll down POST(34592,31,0)
Epg zoom in POST(34592,32,0)
Epg zoom out &POST(34592,33,0)
Epg Show POST(34592,34,0)
Teletext POST(34592,35,0)
Epg background toggle POST(34592,36,0)
Exit POST(34592,99,0)
Stop POST(34592,37,0)
Audio track POST(34592,38,0)
Can EventGhost send POST command to an application?

stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: Plugin for MulticastTV - IPTV client app

Post by stottle » Mon Jun 01, 2009 1:40 pm

EG can handle post messages without any problem. In fact, here's an example plugin to do what you want. The only thing you should need to add is the name of the executable so EG can find the window to post to. Add whatever else you want, change the author name, and you should be good to go.

Note, I don't have MulticastTV, so I can't test this out.

Good luck,
Brett

Code: Select all

version="0.1" 

# Plugins/MulticastTV/__init__.py

eg.RegisterPlugin(
    name = "MulticastTV",
    author = "Brett Stottlemyer",
    version = version,
    kind = "program",
    description = (
        'Adds actions to control MulticastTV - IPTV client app.'
    ),
    createMacrosOnAdd = True,
)

from win32gui import PostMessage

windowMatch = u'NAME OF PROGRAM FROM TASK MANAGER' #<--Change This
myExe = windowMatch + u'.exe'
FindMulticast = eg.WindowMatcher(myExe, None, None, None, None, 1, False, 0.0, 0)

class wmAction(eg.ActionClass):    
    def __call__(self):
        hwnds = FindMulticast()
        if len(hwnds) != 0:
            PostMessage(hwnds[0], 34952, self.value, 0)
        else:
            self.PrintError("Multicast is not running.")
            return

class Multicast(eg.PluginClass):
    def __init__(self):
        self.windowMatch = windowMatch
        self.AddActionsFromList(ACTIONS)

ACTIONS = (
  (wmAction,"Previous", "Previous", "Previous", 65536),
  (wmAction,"1","1","1",1),
  (wmAction,"2","2","2",2),
  (wmAction,"3","3","3",3),
  (wmAction,"4","4","4",4),
  (wmAction,"5","5","5",5),
  (wmAction,"6","6","6",6),
  (wmAction,"7","7","7",7),
  (wmAction,"8","8","8",8),
  (wmAction,"9","9","9",9),
  (wmAction,"0","0","0",0),
  (wmAction,"Volume Down","Volume Down","Volume Down",11),
  (wmAction,"Volume Up","Volume Up","Volume Up",12),
  (wmAction,"Channel Up","Channel Up","Channel Up",13),
  (wmAction,"Channel Down","Channel Down","Channel Down",14),
  (wmAction,"Record","Record","Record",15),
  (wmAction,"Back","Back","Back",16),
  (wmAction,"OSD Channel","OSD Channel","OSD Channel",18),
  (wmAction,"Full Screen","Full Screen","Full Screen",19),
  (wmAction,"Table","Table","Table",20),
  (wmAction,"Mute","Mute","Mute",21),
  (wmAction,"Pause","Pause","Pause",22),
  (wmAction,"Play Faster","Play Faster","Play Faster",23),
  (wmAction,"Play Slower","Play Slower","Play Slower",24),
  (wmAction,"Snapshot","Snapshot","Snapshot",25),
  (wmAction,"Recall","Recall","Recall",26),
  (wmAction,"Aspect Ratio","Aspect Ratio","Aspect Ratio",27),
  (wmAction,"Crop","Crop","Crop",28),
  (wmAction,"Left","Left","Left",102),
  (wmAction,"Right","Right","Right",103),
  (wmAction,"Up","Up","Up",100),
  (wmAction,"Down","Down","Down",101),
  (wmAction,"PIP","PIP","PIP",29),
  (wmAction,"Epg scroll up","Epg scroll up","Epg scroll up",30),
  (wmAction,"Epg scroll down","Epg scroll down","Epg scroll down",31),
  (wmAction,"Epg zoom in","Epg zoom in","Epg zoom in",32),
  (wmAction,"Epg zoom out","Epg zoom out","Epg zoom out",33),
  (wmAction,"Epg Show","Epg Show","Epg Show",34),
  (wmAction,"Teletext","Teletext","Teletext",35),
  (wmAction,"Epg background toggle","Epg background toggle","Epg background toggle",36),
  (wmAction,"Exit","Exit","Exit",99),
  (wmAction,"Stop","Stop","Stop",37),
  (wmAction,"Audio track","Audio track","Audio track",38),
)
Attachments
__init__.py
Here's the plugin as a file. Put this in its own directory in the EG plugins directory
(2.89 KiB) Downloaded 368 times

thehijacker
Posts: 7
Joined: Mon Jun 01, 2009 11:39 am

Re: Plugin for MulticastTV - IPTV client app

Post by thehijacker » Mon Jun 01, 2009 4:21 pm

Hello stottle.

Waw! That was fast. I've put the file inside plugins\MulticastTV folder and added it under Autostart. Now I have two items there. IgorPlug-USB (wich is working fine and accepting commands from my remote) and MulticastTV wich you made.

Where to go next? Where can I see how to create a check to see if application is already running and running it if not yet running? And how to bind the remote control keys to specific item inside plugin (key 1, key 2, ...)? Is there a tutorial somewhere?

And you have to excuse me ignorance. I've just discovered EventGhost :wink:.

PS: You can download the app from here. You do not need IPTV in order to run it and its also in English language :).

stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: Plugin for MulticastTV - IPTV client app

Post by stottle » Mon Jun 01, 2009 5:47 pm

Did you select a macros folder when you installed the Multicast plugin? If so, you should have a folder listed below the autostart items (either in "Centext Folder" or at the bottom). In it are folder (or macros) for each of the actions you provided. The first thing you can do is select one of the actions and hit the green triangle ("execute action") from the top menubar. This will try the action. If MTV isn't running, it will say so in the output log on the left. If it is running, the desired action will be forwarded to MTV.

If everything is working, then what you do is hit a button on your remote, then select the output from the log and drag it to the correct macro folder on the right. At that point, hitting that button should kick off that action (as long as the MTV folder isn't disabled).

As for documentation, there's a getting getting started guideyou can check out in the documentation page.

Brett

thehijacker
Posts: 7
Joined: Mon Jun 01, 2009 11:39 am

Re: Plugin for MulticastTV - IPTV client app

Post by thehijacker » Mon Jun 01, 2009 6:26 pm

Hehe. I can't beleive how simple it is. I had to add the plugin again and it automaticly created folder MulticastTV with all the commands inside. I pressed the keys on my remote and draged them from the log to right panel acording to commands.

The keys work fine, but only for first key. Then no other key works for 5+ seconds and then the next one starts working. For example if I press key 1 and it changes the channel to 1. If I want to change it to 2 by pressing key 2 on my remote it doesn't do anything. I can press it 10+ times and only then it will work in the program. Therefor I am unable to change to lets say channel 12 since I can't press 1+2 key in sequence.

Could this be the bug in MulticastTV or EventGhost? Is there a delay how soon can you send next POST command?

Find attached my saved XML file. I haven't bind all the keys yet. Just few to test it out.
Attachments
MulticastTV.zip
MulticastTV
(951 Bytes) Downloaded 313 times

stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: Plugin for MulticastTV - IPTV client app

Post by stottle » Mon Jun 01, 2009 7:04 pm

I believe that all of the events are handled in a single thread to avoid concurrency issues. Since I've never seen delays like that (there aren't any delays built into EG), my guess is the delay is from waiting for an action in MulticastTV to return. I would check to see if the delay is on the MulticastTV side. At the same time, PostMessage is supposed to fire the message and return, without waiting for the response.

Does the EG icon in the system tray turn red while it's waiting? That's means it is waiting for something to complete. It could also be some delay in the remote (maybe the remote has some delay before it transmits again?) - if this were the case, I would expect EG's icon to stay green.

I'm not sure what else to add, other than I wouldn't expect those delays.

Brett

thehijacker
Posts: 7
Joined: Mon Jun 01, 2009 11:39 am

Re: Plugin for MulticastTV - IPTV client app

Post by thehijacker » Mon Jun 01, 2009 7:11 pm

The icon doesn't stay red. It 'blinks' nicely on each keypress. I've contacted the author of the software. Will see what he has to say about it.

Thanks for now. Excelent support on this forum. You don't see this often.

thehijacker
Posts: 7
Joined: Mon Jun 01, 2009 11:39 am

Re: Plugin for MulticastTV - IPTV client app

Post by thehijacker » Tue Jun 02, 2009 6:19 pm

I've got a reply from the author of the application. He said that he uses OSD which he creates as new transparent window on top of the main one (the main Video window) which eventually leads to having two windows (both with name MulticastTV) and only the first one is able to receive the POST commands.

That is why the first POST command works only when the OSD window closes (after 5 seconds) and then it is able to process the next command.

He tested this with Girder and that application sends POST commands to all the windows inside his application while EventGhost doesn't do that.

He will try to implement receiving of the POST commands to all windows in next versions of his program. But in the mean time, is there a way to tell EventGhost to send POST commands to all the windows of the application?

Thank you.

stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: Plugin for MulticastTV - IPTV client app

Post by stottle » Tue Jun 02, 2009 11:21 pm

If you have both the OSD and the main window open, add a macro and select as the action Window->Find A Window. That will pull up a new configuration window, with a target that you can select and then click on a new window. That gives more info about the target window. Try that on each window (OSD and main) and post the results. I think with that info we can direct the commands to the main window instead of the OSD. I haven't used them, but the WindowMatcher function in the plugin accepts more parameters that can isolate the correct window.

Brett

thehijacker
Posts: 7
Joined: Mon Jun 01, 2009 11:39 am

Re: Plugin for MulticastTV - IPTV client app

Post by thehijacker » Wed Jun 03, 2009 5:01 am

I think I found the main and OSD window. Here is the snipet from XML file:

Code: Select all

<Action>
    Window.FindWindow(u'MulticastTV.exe', u'MulticastTV', u'WindowsForms10.Window.8.app.0.218f99c', u'', u'WindowsForms10.Window.8.app.0.218f99c', 3, False, 0.0, 0)
</Action>
<Action>
    Window.FindWindow(u'MulticastTV.exe', u'OsdWindow', u'WindowsForms10.Window.8.app.0.218f99c', None, None, 1, False, 0.0, 0)
</Action>
If the explanation of the author is correct, I need to send the POST command only to the first main window and not the second OSD one. Basicly EG needs to send the POST command to ALL windows with name MulticastTV and not only the last one opened.

Can this be done.

stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: Plugin for MulticastTV - IPTV client app

Post by stottle » Wed Jun 03, 2009 3:42 pm

The code I posted originally has a WindowMatcher function in it. I think if you replace

Code: Select all

FindMulticast = eg.WindowMatcher(myExe, None, None, None, None, 1, False, 0.0, 0)
with

Code: Select all

FindMulticast = eg.WindowMatcher(myExe, u'MulticastTV', None, None, None, 1, False, 0.0, 0)
it should work. YMMV.

Brett

thehijacker
Posts: 7
Joined: Mon Jun 01, 2009 11:39 am

Re: Plugin for MulticastTV - IPTV client app

Post by thehijacker » Wed Jun 03, 2009 4:22 pm

Omg :).

Its working! Thanks a lot! Now I just need to finish configuring all the key actions.
Attachments
MulticastTV.zip
Plugin + XML
(4 KiB) Downloaded 321 times

stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: Plugin for MulticastTV - IPTV client app

Post by stottle » Wed Jun 03, 2009 6:26 pm

Glad you got it working....

Brett

Post Reply