The lack of up to date documentation makes programming with these VLC plugins a voyage of discovery. I have VLC version '2.0.5 Twoflower' installed and certainly with this one, the useful looking events prefixed with MediaPlayer, e.g. MediaPlayerPositionChanged, never get raised by the AxVLCPlugin2 plugin.
As far as I can tell, polling is required, and to get position/duration information it's the input object that should be queried.
This the interface in C#
namespace AXVLC {
public interface IVLCInput {
double fps { get; }
bool hasVout { get; }
double Length { get; }
double Position { get; set; }
double rate { get; set; }
int state { get; }
double Time { get; set; }
}
}
Time gives the current playback position and Length gives the total duration, both in milliseconds. Position is the current position, scaled 0..1 (1 = 100%).
The state property, which can be conveniently cast to an Enum, has values in the range 0..7, i.e.
Private Enum InputState
IDLE = 0
OPENING = 1
BUFFERING = 2
PLAYING = 3
PAUSED = 4
STOPPING = 5
ENDED = 6
ERRORSTATE = 7
End Enum
I set up a timer with an interval of ~150ms which runs continuously whenever the AxVLCPlugin2 object exists. The following code will write status information to a Label control.
Dim vlc As AxAXVLC.AxVLCPlugin2
Dim infoTimer as System.Windows.Forms.Timer
Dim status as System.Windows.Forms.Label
Private Sub InfoTimer_Tick(sender As Object, e As EventArgs)
Dim state As InputState = DirectCast(vlc.input.state, InputState)
Select Case state
Case InputState.IDLE, InputState.OPENING, InputState.BUFFERING
status.Text = state.ToString()
Exit Select
Case InputState.PLAYING
Dim title As String = System.IO.Path.GetFileName(vlc.mediaDescription.title)
Dim current As TimeSpan = TimeSpan.FromMilliseconds(vlc.input.Time)
Dim total As TimeSpan = TimeSpan.FromMilliseconds(vlc.input.Length)
Dim pos As Double = vlc.input.Position
status.Text = String.Format("{0} {1} {2}:{3:D2}/{4}:{5:D2} {6:P}", state, title, current.Minutes, current.Seconds, total.Minutes, total.Seconds, pos)
Exit Select
Case InputState.PAUSED
status.Text = String.Format("{0} {1}", state, System.IO.Path.GetFileName(vlc.mediaDescription.title))
Exit Select
Case InputState.STOPPING, InputState.ENDED
status.Text = state.ToString()
Exit Select
Case InputState.ERRORSTATE
status.Text = String.Format("{0} {1}", state, vlc.mediaDescription.title)
Exit Select
Case Else
status.Text = state.ToString()
Exit Select
End Select
End Sub
Output while playing would be formatted as
PLAYING filename.ext 1:57/18:50 10.35%
Hope that's of some use. It's all converted from C# so there may be one or two mistakes.
Alan.