Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

How to match a dynamic event?

If you have a question or need help, this is the place to be.
Post Reply
nunos
Posts: 4
Joined: Wed Mar 06, 2013 6:16 pm

How to match a dynamic event?

Post by nunos »

Hi. Just found out about EvenGhost and I am loving it, great stuff! However, can't seem to be able to figure this out on my own.

My goal is to get to the MP3 filename (please see below).

I have a script like this:

Code: Select all

eg.plugins.VLC.NextPlaylistItem()
and I am getting this on the log:

Code: Select all

Python Script
VLC.status change: ( stop state: 0 )
VLC.next: returned 0 (no error)
VLC.status change: ( new input: file:///C:/Users/Admin/Music/some_mp3.mp3 )
VLC.status change: ( audio volume: 204 )
VLC.status change: ( play state: 3 )
VLC.pos: 1%
VLC.status change: ( play state: 4 ): End
VLC.status change: ( play state: 4 ): End
No idea how to match that event, since the message is always different.

Any ideas? Thanks.
nunos
Posts: 4
Joined: Wed Mar 06, 2013 6:16 pm

Re: How to match a dynamic event?

Post by nunos »

In other words, I am playing a playlist in VLC and want to match events of when a music changes, so basically, events like this:

Code: Select all

VLC.status change: ( new input: file:///C:/Users/Admin/Music/mp3_1.mp3 )
VLC.status change: ( new input: file:///C:/Users/Admin/Music/mp3_2.mp3 )
VLC.status change: ( new input: file:///C:/Users/Admin/Music/mp3_3.mp3 )
VLC.status change: ( new input: file:///C:/Users/Admin/Music/mp3_4.mp3 )
I have tried this with no result:

Code: Select all

VLC.status change: ( new input:*)
But I also know, that this kind of events occur, after I do:

Code: Select all

eg.plugins.VLC.NextPlaylistItem()
miljbee
Experienced User
Posts: 146
Joined: Fri Mar 27, 2009 1:29 pm
Location: Orl├®ans, France

Re: How to match a dynamic event?

Post by miljbee »

Ok, I Have just tried the vlc plugin to see how it behaves.

All the info are passed to the event suffix.
This brings a bit complexity.

To be able to retrieve the current playing file, you will have to do a macro that is triggered withh all VLC events.
To do that you have to assign it the VLC.* event (the star only works for full event suffix).

To extract the file name from the event suffix, you will need to parse it in a python script (the python script is a basic eventghost action)
you can access the event suffix with eg.event.suffix

once you have it, you will have to check if it's a new input invent.

something like if (suff.find('new input')>0): should to the trick
then you will have to get rid off all the unneeded stuff (status change: (new input: ...)

in python, you can do that like this :
suff[suff.find("new input: ")+len("new input: "):-2]

the following code can be pasted directly in eventghost (it will create a new folder with 2 macro inside) and should work :

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1610">
    <Folder Name="Display SourceFile" Expanded="True">
        <Macro Name="Read FileName">
            <Event Name="VLC.*" />
            <Action Name="Extract FileName">
                EventGhost.PythonScript(u'suff = eg.event.suffix\nfileName=""\nif (suff.find(\'new input\')>0):\n    fileName=suff[suff.find("new input: ")+len("new input: "):-2]\n    eg.TriggerEvent(prefix="Main",suffix="DisplayVLCSourceFile",payload=fileName)\n    ')
            </Action>
        </Macro>
        <Macro Name="Display VLC Source">
            <Event Name="Main.DisplayVLCSourceFile" />
            <Action>
                EventGhost.ShowOSD(u'{eg.event.payload}', u'0;-64;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (0, 255, 0), (0, 0, 0), 4, (0, 0), 0, 3.0, False)
            </Action>
        </Macro>
    </Folder>
</EventGhost>
miljbee
TCP Events : A Better Network Event Sender/Receiver Plugin.
The Network Event Sender/Receiver in C#
Get events in EG from Google Calendar.
nunos
Posts: 4
Joined: Wed Mar 06, 2013 6:16 pm

Re: How to match a dynamic event?

Post by nunos »

Perfect! You didn't even had to go such a long way to provide the python parse code, that I could have done easily, but anyways, thanks! It works now.

EventGhost is the perfect auomtation tool, really. Where's the donate button? ;)
miljbee
Experienced User
Posts: 146
Joined: Fri Mar 27, 2009 1:29 pm
Location: Orl├®ans, France

Re: How to match a dynamic event?

Post by miljbee »

there isn't but my paypal account is miljbeeatgmaildotcom ;-)
miljbee
TCP Events : A Better Network Event Sender/Receiver Plugin.
The Network Event Sender/Receiver in C#
Get events in EG from Google Calendar.
nunos
Posts: 4
Joined: Wed Mar 06, 2013 6:16 pm

Re: How to match a dynamic event?

Post by nunos »

There should definitely be one for the project! Well, I'll buy you a beer as they say.
Post Reply