///////////////////////// //Player Event Handlers// ///////////////////////// private void musicPlayer_Started(AudioFile NewTrack) { //If the current page is a track page, highlight the row with the playing song TrackPage _currentTrackPage = LibraryFrame.Content as TrackPage; if (_currentTrackPage != null) { _currentTrackPage.RefreshDataContext(); } lblTrackName.Content = $"{NewTrack.Title} - {NewTrack.Artist}"; playPauseButton.DisplayState = PlayButtonDisplayState.Pause; seekBar.StartAnimation(_musicPlayer.GetCurrentTrackLength()); _trackProgressTimer.Start(); lblLength.Content = _musicPlayer.GetCurrentTrackLength().ToString(@"mm\:ss"); }
////////////////// //User Functions// ////////////////// public void ShowTracksPage(string PageHeader, IEnumerable <AudioFile> Tracks, bool ClearSearch = true, Playlist PlaylistContext = null) { ClearSidebarSelection(); TrackPage newPage = new TrackPage(PageHeader, Tracks); newPage.PlaylistContext = PlaylistContext; newPage.TracksSelected += TrackPage_TracksSelected; newPage.ArtistSelected += TrackPage_ArtistSelected; newPage.AlbumSelected += TrackPage_AlbumSelected; newPage.AddToPlaylistSelected += TrackPage_AddPlaylistSelected; newPage.PlaylistUpdated += Trackpage_PlaylistUpdated; newPage.RefreshDataContext(); LibraryFrame.Content = newPage; if (ClearSearch == true) { txtSearch.Clear(); } }
public MainWindow() { _audioDeviceLocater = new AudioDeviceLocater(); //Load app configuration string configFilename = System.IO.Path.Join(AppContext.BaseDirectory, CONFIG_FILENAME); ConfigurationLoader configLoader = new ConfigurationLoader(); configLoader.LoadFromFile(configFilename); _config = configLoader.Configuration; //Get list of Music search locations List <string> searchLocations = new List <string>(); searchLocations.Add(System.IO.Path.Join(AppContext.BaseDirectory, "Music")); searchLocations.AddRange(_config.SearchLocations); _fileLocater = new LocalTrackLocater(searchLocations.ToArray()); //Instantiate requires classes _metadataExtractor = new MetadataExtractor(); _localLibraryManager = new LocalLibraryManager(_fileLocater, _metadataExtractor); _musicPlayer = new MusicPlayer(); _queueBuilder = new QueueBuilder(); _playlistReader = new LocalPlaylistReader(_localLibraryManager, System.IO.Path.Join(AppContext.BaseDirectory, "Playlists")); _playlistWriter = new LocalPlaylistWriter(System.IO.Path.Join(AppContext.BaseDirectory, "Playlists")); _playlistManager = new PlaylistManager(_playlistReader, _playlistWriter); _trackProgressTimer = new DispatcherTimer(); _trackProgressTimer.Interval = TimeSpan.FromSeconds(0.5); _trackProgressTimer.Tick += (_, __) => { lblCurrentTime.Content = _musicPlayer.GetCurrentTrackTimePosition().ToString(@"mm\:ss"); }; //Initialise the search page _searchPage = new TrackPage(); InitializeComponent(); }