AxVLC hangs when changing items rapidly
Posted: 10 Apr 2017 03:24
I'm using the AxVLC component in a legacy VB6 application. If I follow the example from the documentation (https://wiki.videolan.org/Documentation ... ist_object) it functions as expected. That is, if I clear the current playlist, add the desired media item to the playlist, and then execute vlc.Playlist.playItem(0), all is well. Other ways of playing items via a .Playlist with more than one item have proven not to work at all.
Using the above process to render video items (.Playlist.Items.Clear, .Playlist.Add, .Playlist.playItem(0)), the application hangs when the user tries to advance too quickly from one event (playlist item) to the next. Our application plays many diverse items (audio, video, executables, PowerPoint presentations, MS Office documents, PDFs, etc.) and therefore we maintain our own multi-media playlist. During playback, our users can use the right and left keyboard arrow keys to advance from one item to the next/previous. If a user actually holds down the right arrow key, for example, and engages the auto-repeat function, after about 3 or 4 events, the AxVLC seems to hang and the entire application becomes unresponsive.
The above does not happen in the standalone VLC desktop app, of course, so either I'm using vlc.Playlist improperly or there is an issue/bug concerning the speed at which the component can transition from one item to the next.
Included below is the rather straightforward code for our VB6 User Control which wraps AxVLC. Included are some (commented out) sections where I attempted to make the PlaylistPlay method atomic - which had no discernable effect.
Using the above process to render video items (.Playlist.Items.Clear, .Playlist.Add, .Playlist.playItem(0)), the application hangs when the user tries to advance too quickly from one event (playlist item) to the next. Our application plays many diverse items (audio, video, executables, PowerPoint presentations, MS Office documents, PDFs, etc.) and therefore we maintain our own multi-media playlist. During playback, our users can use the right and left keyboard arrow keys to advance from one item to the next/previous. If a user actually holds down the right arrow key, for example, and engages the auto-repeat function, after about 3 or 4 events, the AxVLC seems to hang and the entire application becomes unresponsive.
The above does not happen in the standalone VLC desktop app, of course, so either I'm using vlc.Playlist improperly or there is an issue/bug concerning the speed at which the component can transition from one item to the next.
Included below is the rather straightforward code for our VB6 User Control which wraps AxVLC. Included are some (commented out) sections where I attempted to make the PlaylistPlay method atomic - which had no discernable effect.
Code: Select all
Private strPlaylistURL As String
Private vlcControl As Object
Private hMutex As Long
Public Event MediaPlayerEncounteredError()
Public Event MediaPlayerEndReached()
Public Event MediaPlayerNothingSpecial()
Public Event MediaPlayerStopped()
Public Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Public Event KeyDown(KeyCode As Integer, Shift As Integer)
Public WithEvents vmpPreview As AXVLC.VLCPlugin2
'Private Declare Function CreateMutex Lib "kernel32" Alias "CreateMutexA" (ByVal lpMutexAttributes As Long, ByVal bInitialOwner As Long, ByVal lpName As String) As Long
'Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
'Private Declare Function ReleaseMutex Lib "kernel32" (ByVal hMutex As Long) As Long
'Private Type SECURITY_ATTRIBUTES
' nLength As Long
' lpSecurityDescriptor As Long
' bInheritHandle As Long
'End Type
Private Sub UserControl_Initialize()
Set vlcControl = Controls.Add("VideoLan.VLCPlugin", "vlcControl")
vlcControl.visible = True
Set vmpPreview = vlcControl.object
'Remove pylon logo
vmpPreview.Branding = False 'remove VLC pylon logo by default
vmpPreview.ToolBar = False 'disable video control bar by default
vmpPreview.fullScreenEnabled = False 'disable full screen video mode by default
' hMutex = CreateMutex(0, 1, vbNullString)
End Sub
Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
RaiseEvent KeyDown(KeyCode, Shift)
End Sub
Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseMove(Button, Shift, X, Y)
End Sub
Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseUp(Button, Shift, X, Y)
End Sub
Private Sub UserControl_Resize()
With vlcControl
.Top = 0
.Left = 0
.Width = Width
.Height = Height
.ZOrder 1
End With
End Sub
Private Sub tmrVideoDimensionsTimeout_Timer()
tmrVideoDimensionsTimeout.Enabled = False
End Sub
Public Sub PlaylistPlay(strURL As String)
' WaitForSingleObject hMutex, 10000
' tmrVideoDimensionsTimeout.Enabled = True
' While IsPlaying And tmrVideoDimensionsTimeout.Enabled
' DoEvents
' Wend
' tmrVideoDimensionsTimeout.Enabled = False
strPlaylistURL = strURL
PlaylistClear
Play PlaylistAdd(strURL)
' Play
' ReleaseMutex hMutex
End Sub
Public Sub Play(Optional lngID As Long = 0)
Debug.Print "vmpPreview.Playlist.playItem "; lngID; vmpPreview.Playlist.Items.Count
vmpPreview.Playlist.playItem lngID
' vmpPreview.Playlist.Play
End Sub
Public Function PlaylistAdd(strURL As String) As Long
Const VIDEO_TS = "video_ts.ifo"
Const options = ":avcodec-hw=none"
Dim lngID As Long
If StrConv(GetFileName(strURL), vbLowerCase) <> VIDEO_TS Then
PlaylistAdd = vmpPreview.Playlist.Add("file:///" + strURL, , options)
Else
PlaylistAdd = vmpPreview.Playlist.Add("dvd:///" + GetFileDirectory(strURL), , options)
End If
End Function
Public Sub PlaylistClear()
' Static clearing As Boolean
' If Not clearing Then
' clearing = True
tmrVideoDimensionsTimeout.Enabled = True
While IsPlaying And tmrVideoDimensionsTimeout.Enabled
DoEvents
Wend
tmrVideoDimensionsTimeout.Enabled = False
vmpPreview.Playlist.Items.Clear
' clearing = False
' End If
End Sub
Public Sub PlaylistStop()
vmpPreview.Playlist.pause
volume = 100
vmpPreview.Playlist.stop
Debug.Print "IsPlaying: "; IsPlaying
' tmrVideoDimensionsTimeout.Enabled = True
' While IsPlaying And tmrVideoDimensionsTimeout.Enabled
' DoEvents
' Wend
' tmrVideoDimensionsTimeout.Enabled = False
End Sub
Public Sub FadeIn()
For intVolume = 0 To 100 Step 10
volume = intVolume
Sleep 100
Next
End Sub
Public Sub FadeOut()
For intVolume = 100 To 0 Step 10
volume = intVolume
Sleep 100
Next
End Sub
Public Property Get volume() As Integer
volume = vmpPreview.volume
End Property
Public Property Let volume(nVolume As Integer)
vmpPreview.volume = nVolume
End Property
Public Property Get IsPlaying() As Boolean
IsPlaying = vmpPreview.Playlist.IsPlaying
End Property
Public Property Get PlaylistURL() As String
If IsPlaying Then
Dim nCurrentItem As Integer
nCurrentItem = vmpPreview.Playlist.currentItem
If nCurrentItem > -1 Then PlaylistURL = strPlaylistURL
End If
End Property
Public Property Get VideoWidth() As Integer
tmrVideoDimensionsTimeout.Enabled = True
While VideoWidth <= 10 And tmrVideoDimensionsTimeout.Enabled
DoEvents
VideoWidth = vmpPreview.video.Width
Wend
tmrVideoDimensionsTimeout.Enabled = False
End Property
Public Property Get VideoHeight() As Integer
tmrVideoDimensionsTimeout.Enabled = True
While VideoHeight <= 10 And tmrVideoDimensionsTimeout.Enabled
DoEvents
VideoHeight = vmpPreview.video.Height
Wend
tmrVideoDimensionsTimeout.Enabled = False
End Property
Public Property Get VideoControlBarVisible() As Boolean
VideoControlBarVisible = vmpPreview.ToolBar
End Property
Public Property Let VideoControlBarVisible(visible As Boolean)
vmpPreview.ToolBar = visible
End Property
Public Property Let OwnerForm(objOwner As Object)
Set objParent = objOwner
End Property
'Private Sub vmpPreview_MediaPlayerBackward()
' Debug.Print "MediaPlayerBackward"
'End Sub
'
'Private Sub vmpPreview_MediaPlayerBuffering(ByVal cache As Long)
' Debug.Print "MediaPlayerBuffering"
'End Sub
'
Private Sub vmpPreview_MediaPlayerEncounteredError()
RaiseEvent MediaPlayerEncounteredError
Debug.Print "MediaPlayerEncounteredError"
End Sub
Private Sub vmpPreview_MediaPlayerEndReached()
RaiseEvent MediaPlayerEndReached
Debug.Print "MediaPlayerEndReached"
End Sub
'Private Sub vmpPreview_MediaPlayerForward()
' Debug.Print "MediaPlayerForward"
'End Sub
'
'Private Sub vmpPreview_MediaPlayerLengthChanged(ByVal length As Long)
' Debug.Print "MediaPlayerLengthChanged"
'End Sub
'
'Private Sub vmpPreview_MediaPlayerMediaChanged()
' Debug.Print "MediaPlayerMediaChanged"
'End Sub
'
Private Sub vmpPreview_MediaPlayerNothingSpecial()
RaiseEvent MediaPlayerNothingSpecial
Debug.Print "MediaPlayerNothingSpecial"
End Sub
'Private Sub vmpPreview_MediaPlayerOpening()
' Debug.Print "MediaPlayerOpening"
'End Sub
'
'Private Sub vmpPreview_MediaPlayerPausableChanged(ByVal pausable As Boolean)
' Debug.Print "MediaPlayerPausableChanged"
'End Sub
'
'Private Sub vmpPreview_MediaPlayerPaused()
' Debug.Print "MediaPlayerPaused"
'End Sub
'
'Private Sub vmpPreview_MediaPlayerPlaying()
' Debug.Print "MediaPlayerPlaying"
'End Sub
'
'Private Sub vmpPreview_MediaPlayerPositionChanged(ByVal position As Single)
' Debug.Print "MediaPlayerPositionChanged"
'End Sub
'
'Private Sub vmpPreview_MediaPlayerSeekableChanged(ByVal seekable As Boolean)
' Debug.Print "MediaPlayerSeekableChanged"
'End Sub
'
Private Sub vmpPreview_MediaPlayerStopped()
RaiseEvent MediaPlayerStopped
Debug.Print "MediaPlayerStopped"
End Sub
'Private Sub vmpPreview_MediaPlayerTimeChanged(ByVal time As Long)
' Debug.Print "MediaPlayerTimeChanged"
'End Sub
'
'Private Sub vmpPreview_MediaPlayerTitleChanged(ByVal title As Long)
' Debug.Print "MediaPlayerTitleChanged"
'End Sub