Trackbar
Moving the position clip immediately while the trackbar position is moved
When PlayerTrackBarSynchrone is enabled, moving the trackbar with the mouse updates continuously the position in the video clip, until the mouse button is released. When PlayerTrackBarSynchrone is disabled (default), the position is updated only when the mouse button is released.
This property requires the full trackbar implementation below (unless being using the PlayerTrackbar property under Delphi or C++Builder, see remark below)
TRACKBAR IMPLEMENTATION Remark: when using Delphi or C++Builder, it is possible to put a TTrackbar component on the form, assign it to the PlayerTrackbar property, it will be handled automatically so it is possible to jus tignore the implementations below. Minimal trackbar implementation The minimal trackbar implementation consists to:
- place a trackbar on the form
- create a TVideoGrabber's OnPlayerOpened event, and set the trackbar max position by reading the PlayerFrameCount property from this event
- create a TVideoGrabber's OnPlayerUpdateTrackbarPosition event, and update the trackbar position with the FrameNumber parameter returned by this event
- create a trackbar's OnChange or OnValueChanged event, and update the PlayerFramePosition from this event with the current position of the trackbar
The problem with this minimal implementation is that a jerky trackbar behavior when moving the trackbar thumb while the clip is playing may be noticed, because the trackbar position is upgraded periodically in the background by the OnPlayerUpdateTrackbarPosition event.
FULL TRACKBAR IMPLEMENTATION IN VISUAL STUDIO 1. put a trackbar component on the form 2. create a TVideoGrabber's OnPlayerOpened event that sets the min and max positions of the trackbar, e.g.:
private void axVideoGrabberNET1_OnPlayerOpened(object sender, System.EventArgs e) { tbrPlayer.Minimum = 0; tbrPlayer.TickFrequency = 1; tbrPlayer.Maximum = (int) axVideoGrabberNET1.PlayerFrameCount; }
- create a TVideoGrabber's OnPlayerUpdateTrackbarPosition event that updates the trackbar's position, e.g.:
private void axVideoGrabberNET1_OnPlayerUpdateTrackbarPosition(object sender, Axvidgrab_NET.IVideoGrabberNETEvents_OnPlayerUpdateTrackbarPositionEvent e) { tbrPlayer.Value = (int) e.frameNumber; }
- create a trackbar's OnChange or OnValueChanged event that updates the TVideoGrabber's PlayerFramePosition, e.g:
private void tbrPlayer_ValueChanged(object sender, System.EventArgs e) { axVideoGrabberNET1.PlayerFramePosition = tbrPlayer.Value; }
- create a trackbar's OnMouseDown, OnMouseUp, OnKeyDown and OnKeyUp event that invoke NotifyPlayerTrackbarAction with the corresponding TTrackbarAction parameter, e.g.:
private void tbrPlayer_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { axVideoGrabberNET1.NotifyPlayerTrackbarAction (vidgrab_NET.TxTrackbarAction.tba_MouseDown); }
private void tbrPlayer_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { axVideoGrabberNET1.NotifyPlayerTrackbarAction (vidgrab_NET.TxTrackbarAction.tba_MouseUp); }
private void tbrPlayer_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { axVideoGrabberNET1.NotifyPlayerTrackbarAction (vidgrab_NET.TxTrackbarAction.tba_KeyDown); }
private void tbrPlayer_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { axVideoGrabberNET1.NotifyPlayerTrackbarAction (vidgrab_NET.TxTrackbarAction.tba_KeyUp); } Then run the app, the trackbar should work properly even when moving the thumb while the clip is playing.