Very simple concept, the player sits there listening for events on the serial port, once received, it starts playing that media.
If I put a drop down box on the page and select the media file, it successfully plays the media like this:
Code: Select all
(in "play" button pressed sub)
playMedia(combobox1.selectedItem)
Private Sub playMedia()
Dim vlc As AxAXVLC.AxVLCPlugin2 = AxVLCPlugin21
If (vlc.playlist.items.count > 0) Then
If (vlc.playlist.isPlaying) Then
vlc.playlist.stop()
End If
vlc.playlist.items.clear()
End If
Dim item As Integer = vlc.playlist.add("c:\media\" + mediaString) 'mediastring is global variable
vlc.playlist.playItem(item)
mediaString = ""
End Sub
Code: Select all
Public Delegate Sub myVLCDelegate()
(and in my "event received" subroutine:)
Private Sub DataReceived( _
ByVal sender As Object, _
ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _
Handles serialPort.DataReceived
Dim x As String = serialPort.ReadExisting
mediaString += x
If x = Chr(13) Then
'playMedia(mediaString) '(can't do this - cross thread exception)
If InvokeRequired Then '(this always comes up with "true")
Invoke(New myVLCDelegate(AddressOf playMedia), New Object() {})
End If
End If
End Sub
Any ideas where I'm going wrong please? Seems simple, should work...?