Hello,
I'm trying to get events working with vb.net. I've followed the wiki, and also some of the older posts here but it doesn't work. Anyone got any clues? I want to now whether a zone is playing, paused or stopped.
Public Class MainInterface
#Region "Private Attributes"
'This is the Interface to Media Center
'This is set when Media Center calls the Init Method
Private mediaCenterRef As MediaJukebox.MJAutomation
#End Region
#Region "Media Center Initialisation"
' <summary>
' After the plugin has been created Media Center
' will call the following method, giving us a reference
' to the Media Center interface.
' </summary>
' <param name="mediaCenterReference">
' Media Center Reference
' </param>
Public Sub init(ByVal mediaCenterRef As MediaJukebox.MJAutomation)
Try
Me.mediaCenterRef = mediaCenterRef
Catch ex As Exception
MessageBox.Show("")
End Try
End Sub
#End Region
Dim WithEvents MC As MediaCenter.MCAutomation
Private _RelayEvent As RelayEvent
Delegate Sub RelayEvent(ByVal EventData1 As String, ByVal EventData2 As String, ByVal EventData3 As String)
Public Declare Function tdTurnOn Lib "TelldusCore.dll" (ByVal lngDeviceId As Integer) As Boolean
Public Declare Function tdTurnOff Lib "TelldusCore.dll" (ByVal lngDeviceId As Integer) As Boolean
Public Declare Function tdBell Lib "TelldusCore.dll" (ByVal lngDeviceId As Integer) As Boolean
Public Declare Function tdDim Lib "TelldusCore.dll" (ByVal lngDeviceId As Integer, ByVal level As Byte) As Boolean
Public Declare Function tdMethods Lib "TelldusCore.dll" (ByVal lngDeviceId As Integer, ByVal methodsSupported As Short) As Integer
Public Declare Function tdGetDeviceId Lib "TelldusCore.dll" (ByVal a As Integer) As Integer
Public Declare Function tdGetName Lib "TelldusCore.dll" (ByVal i As Integer) As String
Public Declare Function tdGetNumberOfDevices Lib "TelldusCore.dll" () As Integer
Private Sub MyRelayEvent(ByVal EventData1 As String, ByVal EventData2 As String, ByVal EventData3 As String)
'lbParam1.Text = EventData1
'lbParam2.Text = Trim(EventData2)
' lbParam3.Text = EventData3
' Application.DoEvents()
MsgBox("ahoy")
End Sub
Public Sub MC_FireMJEvent(ByVal s0 As String, ByVal s1 As String, ByVal s2 As String) Handles MC.FireMJEvent
_RelayEvent = New RelayEvent(AddressOf MyRelayEvent)
BeginInvoke(_RelayEvent, s0, s1, s2)
MsgBox("ahoy")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim devices As String = tdGetNumberOfDevices
Dim deviceid(devices - 1) As String
For i As Integer = 0 To devices - 1
deviceid(i) = tdGetDeviceId(i)
Next
tdTurnOn(deviceid(0))
End Sub
End Class