public uint TotalPlayLengthLeft() { uint totalPlayed = 0; foreach (Track t in MediaList.Tracks) { if (MediaList.Tracks.IndexOf(t) >= currentIndex) { if (t.Equals(PlayControl.CurrentTrack.Value)) { totalPlayed += PlayControl.getPlayPosition(); t.PlayPosition = PlayControl.getPlayPosition(); } else { totalPlayed += t.PlayPosition; } } } return(this.TotalPlayLength - totalPlayed); }
public void UpdateTrackSelection() { if (PlayControl.CurrentTrack == null) { return; } if (currentIndex > -1) { uint playLength = PlayControl.getPlayLength(); uint playPosition = PlayControl.getPlayPosition(); /*if (TrackDisplayList.InvokeRequired) * { * TrackDisplayList.Invoke(new MethodInvoker(delegate * { * TrackDisplayList.Items[currentIndex].Selected = true; * if (PlayControl.IsPlaying) * { * TimeSpan t = TimeSpan.FromMilliseconds(playLength - playPosition); * string answer = string.Format("{0:D2}:{1:D2}:{2:D2}", t.Hours, t.Minutes, t.Seconds); * TrackDisplayList.Items[currentIndex].SubItems[1].Text = answer; * } * })); * } * else * {*/ TrackDisplayList.Items[currentIndex].Selected = true; if (PlayControl.IsPlaying) { TimeSpan t = TimeSpan.FromMilliseconds(playLength - playPosition); string answer = string.Format("{0:D2}:{1:D2}:{2:D2}", t.Hours, t.Minutes, t.Seconds); TrackDisplayList.Items[currentIndex].SubItems[1].Text = answer; } //} } }
private void updateGUI() { lblTime.Text = DateTime.Now.ToString("hh:mm:ss tt"); if (PlaylistMedia != null && PlaylistMedia.currentIndex >= 0) { string answer; try { TimeSpan t = TimeSpan.FromMilliseconds(PlayerControl.getPlayLength() - PlayerControl.getPlayPosition()); answer = string.Format("{0:D2}:{1:D2}:{2:D2}", t.Hours, t.Minutes, t.Seconds); lvPlaylist.Items[PlaylistMedia.currentIndex].SubItems[1].Text = answer; t = TimeSpan.FromMilliseconds(PlaylistMedia.TotalPlayLengthLeft()); answer = string.Format("{0:D2}:{1:D2}:{2:D2}", t.Hours, t.Minutes, t.Seconds); } catch (Exception e) { // TODO: Log error to file Program.LogWrite("MainForm::updateGUI(): " + e.ToString()); answer = "00:00:00"; } lblTotalPlayLength.Text = answer; } }