Trackbar

Prev

Next

 






































































































Implementation of a player trackbar

Description


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 you are using the PlayerTrackbar property under Delphi or C++Builder, see remark below)

TRACKBAR IMPLEMENTATION

Remark: if you are using Delphi or C++Builder, you can put a TTrackbar component on your form, assign it to the PlayerTrackbar property, it will be handled automatically so you can jus tignore the implementations below.

Minimal trackbar implementation

The minimal trackbar implementation consists to:

- place a trackbar on your form
- create a TVideoGrabber's OnPlayerOpened event, and set your trackbar max position by reading the PlayerFrameCount property from this event
- create a TVideoGrabber's OnPlayerUpdateTrackbarPosition event, and update your 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 your trackbar

The problem with this minimal implementation is that you may notice a jerky trackbar behavior if you move the trackbar thumb while the clip is playing, 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 your 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;


3. create a TVideoGrabber's OnPlayerUpdateTrackbarPosition event that updates your trackbar's position, e.g.:

private void axVideoGrabberNET1_OnPlayerUpdateTrackbarPosition(object sender, Axvidgrab_NET.IVideoGrabberNETEvents_OnPlayerUpdateTrackbarPositionEvent e)

tbrPlayer.Value = (int) e.frameNumber;


4. 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;


5. 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 your app, the trackbar should work properly even when moving the thumb while the clip is playing.