Esempio n. 1
0
        /// <summary>
        /// Gets a album cover.
        /// </summary>
        /// <param name="albumName">Name of the album.</param>
        /// <param name="tracks">The tracks.</param>
        /// <returns>
        ///     The album cover
        /// </returns>
        public Image GetAlbumCover(string albumName, List <Track> tracks = null)
        {
            if (albumName == AllFilter)
            {
                return(null);
            }

            var cover = AlbumCoverHelper.GetAlbumCover(albumName);

            if (cover != null)
            {
                return(cover);
            }

            DebugHelper.WriteLine("GET ALBUM TRACKS");
            tracks = tracks?.Where(x => x.Album == albumName).ToList() ?? GetAllTracksForAlbum(albumName);

            if (tracks.Count == 0)
            {
                return(null);
            }

            AlbumCoverHelper.LoadAlbumCover(tracks[0]);
            return(AlbumCoverHelper.GetAlbumCover(tracks[0].Album));
        }
Esempio n. 2
0
        public void CopyAudioFromAnotherTrack(Track destinationTrack, Track sourceTrack)
        {
            File.Move(destinationTrack.Filename, destinationTrack.Filename + ".old");

            try
            {
                File.Copy(sourceTrack.Filename, destinationTrack.Filename);
            }
            catch (Exception)
            {
                try
                {
                    File.Move(destinationTrack.Filename + ".old", destinationTrack.Filename);
                }
                catch
                {
                    // ignored
                }
                throw;
            }

            var title       = destinationTrack.Title;
            var album       = destinationTrack.Album;
            var albumArtist = destinationTrack.AlbumArtist;
            var artist      = destinationTrack.Artist;
            var genre       = destinationTrack.Genre;
            var trackNumber = destinationTrack.TrackNumber;

            UpdateTrackDetails(destinationTrack, artist, title, album, albumArtist, genre, trackNumber, false);

            var albumCover = AlbumCoverHelper.GetAlbumCover(destinationTrack.Album);

            if (albumCover != null)
            {
                AlbumCoverHelper.SetTrackAlbumCover(destinationTrack, albumCover);
            }
            File.Delete(destinationTrack.Filename + ".old");

            LoadTrack(destinationTrack.Filename);
        }