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.

Hilfe bei Plugin

Allgemeines zum Thema EventGhost
Post Reply
wxx13
Posts: 2
Joined: Mon Sep 01, 2008 4:33 pm
Location: Germany Berlin

Hilfe bei Plugin

Post by wxx13 »

Hallo EG Gemeinde;
durch Zufall bin ich auf EG gesto├ƒen und von der einfachen Bedienung ├╝berzeugt. Nun m├Âchte ich ein Plugin f├╝r das Programm =http://www.albumplayer.com schreiben. Dieses Programm verf├╝gt ├╝ber ein Remote Control Interface via API Funktion. Da ich hier im Forum keine ausreichenden Infos ├╝ber das Entwickeln von Plugins finden konnte habe ich mir alle in EG enthaltenen Plugins angesehen und das Winamp Plugin als tauglich zum ├ñndern und testen befunden. Da ich mich mit Python gerade erst vertraut mache brauche ich etwas Hilfe.
Hier erst mal die Daten:
Windows XP Sp2
EG Version 0.3.5c 908
FM MCE Toshiba
AlbumPlayer Interface :
Window Messsage (Fenster Nachricht an Albumplayer)
WM_REMOTE_CONTROL = WM_USER + 10;
Parameter:
wparam = 1 -> Play/Pause (Toggle)
wparam = 2 -> Stop
wparam = 3 -> Next Track
wparam = 4 -> Prev Track
wparam = 5 -> Play
wparam = 6 -> Pause
wparam = 7 -> Increase Play Speed Factor
wparam = 8 -> Decrease Play Speed Factor
wparam = 9 -> Seek
lparam -> Position in ms
wparam = 10 -> Set Volume
lparam -> Volume on a scale of 0 to 100
wparam = 11 -> Increase/Decrease Volume
lparam -> Steps on a volume scale of 0 to 100 (step max -100 to 100)
wparam = 12 -> Mute (Toggle)
wparam = 100 -> BringToFront
wparam = 101 -> Exit

WM_SUBSCRIBE_FOR_NOTIFICATIONS = WM_USER + 11;
The AP can send the following notifications using different parameters:
Now playing info:
wparam = 6 -> track progress changed
lparam -> progress in milliseconds
Playlist:
wparam = 10 -> playlist is changed
Player status:
wparam = 1 -> play state changed
lparam = 0 -> stopped
lparam = 1 -> playing
lparam = 2 -> paused
wparam = 12 -> albumplayer volume changed
lparam -> volume percentage (0-100)
General:
wparam = 2 -> albumplayer will be closed

Das ganze habe ich nun fogendermaßen als Plugin umgesetzt.

Code: Select all

import eg
class PluginInfo(eg.PluginInfo):
    name = "AlbumPlayer"
    author = "Klaus Muens"
    version = "1.0.0"
    kind = "program"
    description = "Adds support functions to control AlbumPlayer"
    icon = (
        "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARn"
        "QU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdw"
        "nLpRPAAAAZVJREFUOE+tk8srRFEcx++wGK+SvMozWZk8Y6OMZ8pOUlZWCisbG6z9AczS"
        "EhEy2XgkjREz95qYQR4ZsRBRFkrD9Rwf955LkxrK5NTv/M7ifD99z+/3OyZJkqizVmvp"
        "78u5sS5JmphIl679Z4CjE8YKYFSLhXp4UQl491BMqchSEi4pHo85k/OBQWH6u4O3Z03U"
        "agD0mCsneHvJw/4Rm7Hp7BZXcjU8ghyViC+/IgxAvYHZOpgoM/KUhbeLLe4Pj5Hjkjls"
        "aiaoPgrIdl5RGMCtPyRe7YZpCy/7dh6O/ChxaeyVW4VYMafgzS0NA7iWDeuLbUZTNAfP"
        "LpsAeOJzkE3JuKMTxPmsqzcM4NRuAOZbwNUHkxZenf2o/hOUmEwUKVU4CGztEHzS6vVV"
        "xPqaWngPwo4tVEAdNF7Au7ODJ/8BcmyW6ETA4/s2MqEuBC5grccALLcbl/TzUiOqz43b"
        "nCEAd86NHwD6+x1dMFMFviHjkr0BVlq4lx14C614s0t+cRDhLP/PKH/+RjGWfw1dq/9h"
        "fYs4PgCmlMFgdKLWGAAAAABJRU5ErkJggg=="
    )

import wx
from win32gui import FindWindow, SendMessageTimeout, GetWindowText
from win32con import WM_COMMAND, WM_USER, SMTO_BLOCK, SMTO_ABORTIFHUNG

def FindWindow():
    """
    Find AlbumPlayer's message window.
    """
    try:
        hWnd = FindWindow("Albumplayer","TfrmPlayer")
    except:
        hWnd = None
    return hWnd

def SendMessage(mesg, wParam, lParam=0):
    """
    Find AlbumPlayer's message window and send it a message with 
    SendMessageTimeout.
    """
    try:
        hWnd = FindWindow('Albumplayer','TfrmPlayer')
        _, result = SendMessageTimeout(
            hWnd,
            mesg, 
            wParam, 
            lParam, 
            SMTO_BLOCK|SMTO_ABORTIFHUNG,
            2000 # wait at most 2 seconds
        )
        return result
    except:
        eg.PrintError("AlbumPlayer is not running")

def GetPlayingStatus():
    """
    Get the current status of AlbumPlayer.
    
    The return value is one of the strings 'playing', 'paused' or 'stopped'.
    """
    iStatus = SendMessage(WM_USER + 11, 1, 0)
    if iStatus == 1:
        return 'playing'
    elif iStatus == 2:
        return 'paused'
    else:
        return 'stopped'

class TogglePlay(eg.ActionClass):
name = "Toggle Play"
    description = "Toggles between play and pause of Albumplayer."
def __call__(self):
        if GetPlayingStatus() == "stopped":
           self.plugin.Play()
        else:
            self.plugin.Pause()

class Play(eg.ActionClass):
description = "Simulate a press on the play button."
    
    def __call__(self):
        return SendMessage(WM_USER + 10, 1, 0)

class Pause(eg.ActionClass):
    description = "Simulate a press on the pause button."
    
    def __call__(self):
        return SendMessage(WM_USER + 10, 6, 0)

Beim Start von EG lade ich das X10 und das APlayer Plugin.Keine Fehleranzeige alles wird normal geladen, das Icon wird angezeigt und die Befehle in EG ├╝ber die MCE Fernbedienung werden ausgef├╝hrt. Im Zielprogramm das ich Fernbedienen will geschieht allerdings garnichts.
Andere Funktionen der Fernbedienung arbeiten in EG einwandfrei.
Ich gehe also davon aus das sich ein krasser Fehler in dem Plugin befindet !

F├╝r jeden Hinweis bin ich dankbar.
Gruss Klaus
User avatar
topix
Experienced User
Posts: 441
Joined: Sat May 05, 2007 3:43 pm
Location: Germany
Contact:

Re: Hilfe bei Plugin

Post by topix »

Ich kenn mich zwar nicht mit der Pluginerstellung aus, aber wollte trotzdem mal dein Plugin probieren. Dabei ist mir aufgefallen, das sich bei den Plugins wohl einiges verändert hat. Ich benutze EG 3.6.1449 (http://www.eventghost.org/downloads/). Da kann ich den Code von oben nicht als Plugin verwenden.
wxx13
Posts: 2
Joined: Mon Sep 01, 2008 4:33 pm
Location: Germany Berlin

Re: Hilfe bei Plugin

Post by wxx13 »

Hallo Topix ;
danke f├╝r den Hinweis. Habe mir die aktuelle Version heruntergeladen, ein wenig probiert und siehe da mein Plugin funktioniert. Werde nur noch ein bisschen herumfeilen, eine Beschreibung hinzuf├╝gen und es der EG Gemeinde dann zur verf├╝gung stellen.
Vielen Dank Klaus
Post Reply