/// <summary> /// Handles the Scroll event of the colorSlider1 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.ScrollEventArgs"/> instance containing the event data.</param> private void colorSlider1_Scroll(object sender, ScrollEventArgs e) { double seekPosition = 0; // Gets the seek position value: seekPosition = ((double)this.colorSlider1.Value / this.colorSlider1.Maximum) * duration; if (IsPlayingCompleted(seekPosition)) { Stop(); } if (isLocalFile) { // Set the current position directly: if (ourVideo != null) { ourVideo.CurrentPosition = seekPosition; } } else { if (rtspClient != null) { // Judges this position can be play or not: bool result = rtspClient.IsContinuePlaying(seekPosition); if (result) { // Set the current position directly: if (ourVideo != null) { ourVideo.CurrentPosition = seekPosition; } } else { // Pauses the current playing: Pause(); // Seeks the stream and wait for playing: result = rtspClient.SeekStream(seekPosition); if (!result) { Stop(); } // Sets the current position which will be shown to the user. this.colorSlider1.Value = (int)((seekPosition / duration) * this.colorSlider1.Maximum); this.lblCurrentPos.Text = Utils.ConvertTimeToString(seekPosition); // Sets the current state to the play buffering: currentState = PlayerState.Buffering; UpdateClientStatus(); } } } }