/// <summary> /// Plays a selected track from ListView /// </summary> /// <param name="selectedTrack"></param> private void playSelectedTrack(TrackMetadata selectedTrack) { if (SelectAllTracks != true) { musicplayer.SetActiveTrackInPlayableContainer(TracksManager.db_GetAllTracks().Find(x => x.title == selectedTrack.Title)); playMusic(); } else { musicplayer.SetActiveTrack(TracksManager.db_GetAllTracks().Find(x => x.title == selectedTrack.Title)); playMusic(); SelectAllTracks = false; } }
/// <summary> /// Passes data from all tracks to View /// </summary> private void createTracksView() { TitleViewModel.Tracks.Clear(); foreach (Track track in TracksManager.db_GetAllTracks()) { TrackMetadata md = new TrackMetadata(); if (track.title == null) { md.Title = "unkown"; MetadataEditor.AddTitle(track.audio, "unknown"); } else { md.Title = track.title; MetadataEditor.AddTitle(track.audio, track.title); } if (MetadataEditor.GetGenres(track.audio) == null || MetadataEditor.GetGenres(track.audio).Count() == 0) { md.Genre = "unkown"; MetadataEditor.AddGenre(track.audio, new String[] { "unknown" }); } else { md.Genre = MetadataEditor.GetGenres(track.audio)[0]; } if (MetadataEditor.GetArtists(track.audio) == null || MetadataEditor.GetArtists(track.audio).Count() == 0) { md.Artist = "unknown"; MetadataEditor.AddArtist(track.audio, new String[] { "unknown" }); } else { md.Artist = MetadataEditor.GetArtists(track.audio)[0]; } if (MetadataEditor.GetYear(track.audio) == 0) { md.Year = "unknown"; } else { md.Year = MetadataEditor.GetYear(track.audio).ToString(); } if (MetadataEditor.GetAlbum(track.audio) == null) { md.Album = "unknown"; MetadataEditor.AddAlbum(track.audio, "unknown"); } else { md.Album = MetadataEditor.GetAlbum(track.audio); } if (MetadataEditor.GetDuration(track.audio).ToString(@"hh\:mm\:ss") == "00:00:00") { md.Length = "unknown"; } else { md.Length = MetadataEditor.GetDuration(track.audio).ToString(@"hh\:mm\:ss"); } TitleViewModel.Tracks.Add(md); } SelectAllTracks = true; CurrentFrame = "TitleView.xaml"; }
/// <summary> /// Plays a selected track from ListView /// </summary> /// <param name="selectedTrack"></param> private void playSelectedTrack(TrackMetadata selectedTrack) { MainViewModel.musicplayer.SetActiveTrack(TracksManager.db_GetAllTracks().Find(x => x.title == selectedTrack.Title)); mainViewModel.playMusic(); }