private void timerGetPosition_Tick(object sender, EventArgs e) {
if (timerGetPositionEnabled) {
if ((EndPos.HasValue && position > EndPos && !IgnorePos) || position > CurrentVideo.Length - 1) {
// End position reached.
if (PlayNext != null) {
//timerGetPositionEnabled = false;
player.Dispatcher.Invoke(() => PlayNext(this, new EventArgs()));
}
} else if (restorePosition == 0 && StartPos.HasValue && StartPos > 10 && position < StartPos && !IgnorePos) {
// Skip to start position.
restorePosition = StartPos.Value;
}
if (restorePosition > 0) {
// Restore to specified position (usually after a crash).
if (restorePosition > 10) {
timerGetPositionEnabled = false;
position = restorePosition;
player.Position = restorePosition;
timerGetPositionEnabled = true;
}
restorePosition = 0;
} else
TrackPosition();
}
}