FormatTime() public static method

public static FormatTime ( float seconds ) : string
seconds float
return string
Esempio n. 1
0
        private void GetFileMetadata(string path)
        {
            try
            {
                if (!File.Exists(path))
                {
                    return;
                }

                var fm = new FileMetadata(path);

                this.SongTitle       = fm.Title.Value;
                this.SongAlbum       = fm.Album.Value;
                this.SongArtists     = string.Join(", ", fm.Artists.Values);
                this.SongGenres      = string.Join(", ", fm.Genres.Values);
                this.SongYear        = fm.Year.Value.ToString();
                this.SongTrackNumber = fm.TrackNumber.Value.ToString();
                this.AudioDuration   = FormatUtils.FormatTime(fm.Duration);
                this.AudioType       = fm.Type;
                this.AudioSampleRate = string.Format("{0} {1}", fm.SampleRate.ToString(), "Hz");
                this.AudioBitrate    = string.Format("{0} {1}", fm.BitRate.ToString(), "kbps");
            }
            catch (Exception ex)
            {
                LogClient.Error("Error while getting file Metadata. Exception: {0}", ex.Message);
            }
        }
        protected override void GetPlayBackServiceProgress()
        {
            base.GetPlayBackServiceProgress();

            this.CurrentTime = FormatUtils.FormatTime(this.playBackService.GetCurrentTime);
            this.TotalTime   = FormatUtils.FormatTime(this.playBackService.GetTotalTime);
        }
Esempio n. 3
0
        private void UpdateTime()
        {
            if (this.PlaybackInfoViewModel == null)
            {
                return;
            }

            this.PlaybackInfoViewModel.CurrentTime = FormatUtils.FormatTime(this.playbackService.GetCurrentTime);
            this.PlaybackInfoViewModel.TotalTime   = " / " + FormatUtils.FormatTime(this.playbackService.GetTotalTime);
        }
        private async void RefreshPlaybackInfoAsync(PlayableTrack track, bool allowRefreshingCurrentTrack)
        {
            await Task.Run(() =>
            {
                this.previousTrack = this.track;

                // No track selected: clear playback info.
                if (track == null)
                {
                    this.ClearPlaybackInfo();
                    return;
                }

                this.track = track;

                // The track didn't change: leave the previous playback info.
                if (!allowRefreshingCurrentTrack & this.track.Equals(this.previousTrack))
                {
                    return;
                }

                // The track changed: we need to show new playback info.
                try
                {
                    string year = string.Empty;

                    if (track.Year != null && track.Year > 0)
                    {
                        year = track.Year.ToString();
                    }

                    this.PlaybackInfoViewModel = new PlaybackInfoViewModel
                    {
                        Title       = string.IsNullOrEmpty(track.TrackTitle) ? track.FileName : track.TrackTitle,
                        Artist      = track.ArtistName,
                        Album       = track.AlbumTitle,
                        Year        = year,
                        CurrentTime = FormatUtils.FormatTime(new TimeSpan(0)),
                        TotalTime   = FormatUtils.FormatTime(new TimeSpan(0))
                    };
                }
                catch (Exception ex)
                {
                    LogClient.Error("Could not show playback information for Track {0}. Exception: {1}", track.Path, ex.Message);
                    this.ClearPlaybackInfo();
                }

                this.RaisePropertyChanged(nameof(Rating));
                this.RaisePropertyChanged(nameof(Love));
                this.UpdateTime();
            });
        }
Esempio n. 5
0
        private void ShowPlaybackInfoAsync(TrackInfo iTrackInfo)
        {
            if (iTrackInfo == null)
            {
                this.PlaybackInfoViewModel = new PlaybackInfoViewModel
                {
                    Title       = string.Empty,
                    Artist      = string.Empty,
                    Album       = string.Empty,
                    Year        = string.Empty,
                    CurrentTime = string.Empty,
                    TotalTime   = string.Empty
                };
                return;
            }

            try
            {
                string year = string.Empty;

                if (iTrackInfo.Year != null && iTrackInfo.Year > 0)
                {
                    year = iTrackInfo.Year.ToString();
                }

                this.PlaybackInfoViewModel = new PlaybackInfoViewModel
                {
                    Title       = string.IsNullOrEmpty(iTrackInfo.TrackTitle) ? iTrackInfo.FileName : iTrackInfo.TrackTitle,
                    Artist      = iTrackInfo.ArtistName,
                    Album       = iTrackInfo.AlbumTitle,
                    Year        = year,
                    CurrentTime = FormatUtils.FormatTime(new TimeSpan(0)),
                    TotalTime   = FormatUtils.FormatTime(new TimeSpan(0))
                };
            }
            catch (Exception ex)
            {
                LogClient.Instance.Logger.Error("Could not show playback information for Track {0}. Exception: {1}", iTrackInfo.Path, ex.Message);
                this.PlaybackInfoViewModel = new PlaybackInfoViewModel
                {
                    Title       = string.Empty,
                    Artist      = string.Empty,
                    Album       = string.Empty,
                    Year        = string.Empty,
                    CurrentTime = string.Empty,
                    TotalTime   = string.Empty
                };
            }

            this.UpdateTime();
        }
 public ProgressControlsWithTimeViewModel() : base(ServiceLocator.Current.GetInstance <IPlaybackService>())
 {
     this.CurrentTime = FormatUtils.FormatTime(new TimeSpan(0));
     this.TotalTime   = FormatUtils.FormatTime(new TimeSpan(0));
 }
 protected void UpdateTime()
 {
     this.PlaybackInfoViewModel.CurrentTime = FormatUtils.FormatTime(this.playbackService.GetCurrentTime);
     this.PlaybackInfoViewModel.TotalTime   = " / " + FormatUtils.FormatTime(this.playbackService.GetTotalTime);
 }