private void ReadFiles(IEnumerable <string> files)
        {
            try
            {
                //get the files and sort by trackNumber
                var containers = _fileRetriever.GetContainers(files);
                containers = ZuneAudioFileRetriever.SortByTrackNumber(containers);

                //get the first tracks metadata which is used to set some details
                MetaData firstTrackMetaData = containers.First().MetaData;

                //set the album details that is used throughout the app
                _sharedModel.AlbumDetailsFromFile = SharedMethods.SetAlbumDetails(firstTrackMetaData, containers.Count);
                _sharedModel.SongsFromFile        = containers;

                //as soon as the view has switched start searching
                var searchVm = _locator.SwitchToView <SearchView, SearchViewModel>();
                searchVm.Search(firstTrackMetaData.AlbumArtist, firstTrackMetaData.AlbumName);
            }
            catch (Exception ex)
            {
                Messenger.Default.Send(new ErrorMessage(ErrorMode.Error, ex.Message));
                return;  //if we hit an error on any track in the albums then just fail and dont read anymore
            }
        }
Exemplo n.º 2
0
        public void DelinkAlbum()
        {
            Mouse.OverrideCursor = Cursors.Wait;

            //TODO: fix bug where application crashes when removing an album that is currently playing

            var filePaths = _dbReader.GetTracksForAlbum(MediaId).Select(x => x.FilePath);

            var containers = _fileRetriever.GetContainers(filePaths);

            foreach (var container in containers)
            {
                container.RemoveZuneAttribute("WM/WMContentID");
                container.RemoveZuneAttribute("WM/WMCollectionID");
                container.RemoveZuneAttribute("WM/WMCollectionGroupID");
                container.RemoveZuneAttribute("ZuneCollectionID");
                container.RemoveZuneAttribute("WM/UniqueFileIdentifier");
                container.RemoveZuneAttribute("ZuneCollectionID");
                container.RemoveZuneAttribute("ZuneUserEditedFields");
                container.RemoveZuneAttribute(ZuneIds.Album);
                container.RemoveZuneAttribute(ZuneIds.Artist);
                container.RemoveZuneAttribute(ZuneIds.Track);
                container.WriteToFile();
            }

            Mouse.OverrideCursor = null;

            Messenger.Default.Send(new ErrorMessage(ErrorMode.Warning,
                                                    "Album should now be de-linked. You may need to " +
                                                    "remove then re-add the album for the changes to take effect."));

            //force a refresh on the album to see if the de-link worked
            //this probably wont work because the zunedatabase does not correctly change the albums
            //details when delinking, but does when linking
            RefreshAlbum();
        }