i am using the background audio player to play an audio file.I have tried to get the duration of the audio using the background.instance.track.duration.totalseconds method.But when i run the app method returned "0" everytime.The duration is retrieved if i run the code through breakpoints. Below is my code.
if (BackgroundAudioPlayer.Instance.PlayerState != PlayState.Playing)
{
progressBar1.Visibility = System.Windows.Visibility.Visible;
TotalTimeDisplay.Visibility = System.Windows.Visibility.Visible;
//this.TotalTimeDisplay.Time = TimeSpan.Parse("00:00:00.0");
imgplay.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("Images/player_pause_new.png", UriKind.Relative));
AudioTrack audioTrack = new AudioTrack(new Uri("a" + imgname + ".MP3", UriKind.Relative), "", "", "", null);
BackgroundAudioPlayer.Instance.Track = audioTrack;
duration = BackgroundAudioPlayer.Instance.Track.Duration.TotalMilliseconds;
}
Please suggest the solution .Thanks in advance.