dbraner Posted April 18, 2009 Share Posted April 18, 2009 (edited) Hi guys, after a long time of (unsuccessful) attempts handling DVBViewer COM events in C++ and Visual Basic Script I figured out how to catch events using AutoIT scripting. Here's an example: ; Eventhandler for onAction Func Event_onAction ($ActionId) MsgBox (0, "Event", "onAction") EndFunc ; Get running DVBViewer instance $DVBViewer = ObjGet ("", "DVBViewerServer.DVBViewer") If $DVBViewer = 0 Then MsgBox (1, "DVBVCommand", "DVBViewer not running") Exit EndIf ; Install the event handler ObjEvent ($DVBViewer.Events, "Event_", "IDVBViewerEvents") If @error = 0 Then ; This is an endless loop. Maybe there's a better solution for waiting for events While (1) Sleep (500) WEnd Else MsgBox (0, "Error", "Error = " & @error) EndIf The possible events are documented in the COM interface help file. Simply add your eventhandler functions to the code, i.e. onPlaystateChange. Unfortunately my C++ code is still not working ... Edited April 18, 2009 by dbraner Quote Link to comment
nuts Posted April 19, 2009 Share Posted April 19, 2009 (edited) Danke edit \ sehr cool OnPlaystatechange wird aufgerufen wenn die wiedergabe einer mediendatei beendet wird. damit sollte sich doch was basteln lassen um die schwarzen bildschirme nach der dateiwiedergabe zu verhindern. hast du schon rausgefunden wie man die verschiedenen parameter in der eventfunktionen verwenden kann? edit2 \ achso ganz leicht: einfach den paramter in der msgbox abfragen! sehr cool Edited April 19, 2009 by nuts Quote Link to comment
dbraner Posted April 19, 2009 Author Share Posted April 19, 2009 (edited) On more example for handling OnPlaystateChange event. The following code catches an OnPlaystateChange event and stores the new playstate in a datamanager property. Now it's easy to access this datamanager property from within your command.vbs script. You will always have the current playstate. Dim $DVBViewer Func Event_onPlaystateChange ($RenderType, $State) $DVBViewer.Datamanager.Value ("#EventCurrentRenderType") = $RenderType $DVBViewer.Datamanager.Value ("#EventCurrentPlayState") = $State EndFunc $DVBViewer = ObjGet ("", "DVBViewerServer.DVBViewer") If $DVBViewer = 0 Then MsgBox (1, "DVBVCommand", "DVBViewer not running") Exit EndIf ObjEvent ($DVBViewer.Events, "Event_", "IDVBViewerEvents") If @error = 0 Then While (1) Sleep (500) WEnd Else MsgBox (0, "Error", "Error = " & @error) EndIf This is only a workaround. A better solution is that Lars is setting this property in his code directly. For possible render types and playstates see COM helpfile. In your command.vbs you can access the new properties by using Datamanager.Value ("#EventCurrentPlayState") Have fun! Dirk Edited April 19, 2009 by dbraner Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.