Jump to content

HOWTO: Handle DVBViewer Events with AutoIT


dbraner

Recommended Posts

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 ... :D

Edited by dbraner
Link to comment

Danke :D

 

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 by nuts
Link to comment

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 by dbraner
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...