hello... i am working on a simple media player in a 2012 VS C# WPF project. The media element works fine... a little glitchy but i'm working on that, but i am having problems with my count down timer. i'm not sure how to get it into the ("HH:mm:ss") format... I've tried different ways and i'm not making progress and i'm not sure why... here's what i have:
using system.windows.threading;
public partial class MainWindow : Window
{
DispatcherTimer timer;
int countDwn;
public MainWindow()
{
InitializeComponent();
timer = new DispatcherTimer();
timer.Tick += new EventHandler(timer_Tick);
timer.Interval = new TimeSpan(0, 0, 1);
timer.Start();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
}
private void myMediaElement_MediaOpened(object sender, RoutedEventArgs e)
{
TimeSpan ts = myMediaElement.NaturalDuration.TimeSpan;
sliderSeek.Maximum = ts.TotalSeconds;
timer.Start();
}
private void sliderSeek_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
myMediaElement.Position = TimeSpan.FromSeconds(sliderSeek.Value);
}
void timer_Tick(object sender, EventArgs e)
{
sliderSeek.Value = myMediaElement.Position.TotalSeconds;
countDwn = (int)sliderSeek.Maximum - (int)sliderSeek.Value;
cntDwnLbl.Content = countDwn;
}
it counts down correctly but it's in seconds. i can't seem to get it in "HH:mm:ss" format, i've tried various way and read different forum posts but haven't resolved this issue yet. any help would be great. thanks.
Adam