Ejemplo n.º 1
0
    public override int GetHashCode()
    {
        int hashcode = 157;

        unchecked {
            hashcode = (hashcode * 397) + IdTrack.GetHashCode();
            if (__isset.trackNumber)
            {
                hashcode = (hashcode * 397) + TrackNumber.GetHashCode();
            }
            if (__isset.durationSeconds)
            {
                hashcode = (hashcode * 397) + DurationSeconds.GetHashCode();
            }
            if (__isset.storagePath)
            {
                hashcode = (hashcode * 397) + StoragePath.GetHashCode();
            }
            if (__isset.title)
            {
                hashcode = (hashcode * 397) + Title.GetHashCode();
            }
            if (__isset.gender)
            {
                hashcode = (hashcode * 397) + Gender.GetHashCode();
            }
        }
        return(hashcode);
    }
Ejemplo n.º 2
0
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = TrackId;
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Artist != null ? Artist.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AlbumArtist != null ? AlbumArtist.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Composer != null ? Composer.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Album != null ? Album.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Genre != null ? Genre.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Kind != null ? Kind.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Size.GetHashCode();
         hashCode = (hashCode * 397) ^ (PlayingTime != null ? PlayingTime.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ TrackNumber.GetHashCode();
         hashCode = (hashCode * 397) ^ Year.GetHashCode();
         hashCode = (hashCode * 397) ^ DateModified.GetHashCode();
         hashCode = (hashCode * 397) ^ DateAdded.GetHashCode();
         hashCode = (hashCode * 397) ^ BitRate.GetHashCode();
         hashCode = (hashCode * 397) ^ SampleRate.GetHashCode();
         hashCode = (hashCode * 397) ^ PlayCount.GetHashCode();
         hashCode = (hashCode * 397) ^ PlayDate.GetHashCode();
         hashCode = (hashCode * 397) ^ PartOfCompilation.GetHashCode();
         return(hashCode);
     }
 }
Ejemplo n.º 3
0
    private void DebugClicked(ClickEvent ev)
    {
        FFB.Instance.Model.HomeCoach = new Coach()
        {
            Name   = "Foo",
            IsHome = true
        };

        FFB.Instance.Model.AwayCoach = new Coach()
        {
            Name   = "Bar",
            IsHome = false
        };


        ev.StopPropagation();
        var pos = new Fumbbl.Model.Types.Position();

        pos.IconURL     = "i/585610";
        pos.PortraitURL = "i/318621";
        Player p = new Player();

        p.Position    = pos;
        p.Id          = "Debug Player " + UnityEngine.Random.Range(1, 1000);
        p.Coordinate  = new Coordinate(UnityEngine.Random.Range(1, 25), UnityEngine.Random.Range(1, 14));
        p.PlayerState = PlayerState.Get(UnityEngine.Random.Range(1, 5));
        FFB.Instance.Model.Add(p);

        var trackNumber = new TrackNumber()
        {
            Coordinate = new Coordinate(UnityEngine.Random.Range(1, 25), UnityEngine.Random.Range(1, 14)),
            Number     = UnityEngine.Random.Range(1, 10)
        };

        FFB.Instance.Model.Add(trackNumber);

        var pushbackSquare = new PushbackSquare()
        {
            Coordinate = new Coordinate(UnityEngine.Random.Range(1, 25), UnityEngine.Random.Range(1, 14)),
            Direction  = "West"
        };

        FFB.Instance.Model.Add(pushbackSquare);

        FFB.Instance.Model.ActingPlayer.PlayerId = p.Id;

        for (int i = 0; i < 20; i++)
        {
            FFB.Instance.AddReport(RawString.Create($"<b>* * * Test message {i} * * *</b>"));
            FFB.Instance.AddChatEntry(i % 2 == 0 ? "Foo" : "Bar", $"Test Chat message {i} - long line to force line wrapping to happen... Blah blah blah.");
        }
    }
Ejemplo n.º 4
0
        internal void Add(TrackNumber square)
        {
            int key = square.coordinate[0] * 100 + square.coordinate[1];

            if (!TrackNumbers.ContainsKey(key))
            {
                TrackNumbers.Add(key, new View.TrackNumber(square));
            }
            else
            {
                TrackNumbers[key].Refresh(new View.TrackNumber(square));
            }
        }
Ejemplo n.º 5
0
        protected override int CompareMediaItems(MediaItem mediaItem)
        {
            if (Type == mediaItem.Type)
            {
                Song song = mediaItem as Song;

                if (Genre == song.Genre)
                {
                    if (Artist == song.Artist)
                    {
                        if (Album == song.Album)
                        {
                            if (DiskNumber == song.DiskNumber)
                            {
                                if (TrackNumber == song.TrackNumber)
                                {
                                    return(Name.CompareTo(song.Name));
                                }
                                else
                                {
                                    return(TrackNumber.CompareTo(song.TrackNumber));
                                }
                            }
                            else
                            {
                                return(DiskNumber.CompareTo(song.DiskNumber));
                            }
                        }
                        else
                        {
                            return(Album.CompareTo(song.Album));
                        }
                    }
                    else
                    {
                        return(Artist.CompareTo(song.Artist));
                    }
                }
                else
                {
                    return(Genre.CompareTo(song.Genre));
                }
            }
            else
            {
                return(Type.CompareTo(mediaItem.Type));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns a string field
        /// </summary>
        /// <param name="name">Name of field</param>
        /// <returns></returns>
        public string this[string name]
        {
            get
            {
                switch (name.ToLower())
                {
                case "title":
                    return(Title);

                case "artist":
                    return(Artist);

                case "album":
                    return(Album);

                case "genre":
                    return(Genre);

                case "rating":
                    return(RatingString);

                case "length":
                    return(LengthString);

                case "play count":
                    return(PlayCount.ToString());

                case "date added":
                    return(DateAdded.ToShortTimeString());

                case "last played":
                    return(LastPlayed.ToShortDateString());

                case "track number":
                    return(TrackNumber.ToString());

                case "disc number":
                    return(DiscNumber.ToString());

                default:
                    return(null);
                }
            }
        }
Ejemplo n.º 7
0
        public void RenameFile()
        {
            CheckValidness();

            string new_name = (Album.TotalDisc > 1 ? Album.TotalDisc + "-" : "")
                              + TrackNumber.ToString().PadLeft(2, '0') + " "
                              + PathUtils.FixPathString(this.Name)
                              + "." + Path.GetExtension(FullPath);

            // make sure the name is not too long
            if (new_name.Length > 180)
            {
                new_name = new_name.Substring(0, 180);
            }

            File.Move(FullPath, Path.Combine(Album.Location, new_name));

            FileName = new_name;
            Update();
        }
Ejemplo n.º 8
0
        public void Save(XmlWriter writer)
        {
            SaveBase(writer);

            if (album != null)
            {
                writer.WriteElementString("album", album);
            }

            // Only write valid (ie non-0) track numbers
            if (TrackNumber > 0)
            {
                writer.WriteElementString("trackNum", TrackNumber.ToString());
            }

            foreach (Uri uri in locations)
            {
                string escaped = uri.IsAbsoluteUri? uri.AbsoluteUri : Uri.EscapeUriString(uri.ToString());
                writer.WriteElementString("location", escaped);
            }
        }
        /// <inheritdoc/>
        public virtual int CompareTo(SegmentModelBase other)
        {
            // If other is not a valid object reference, this instance is greater.
            if (other == null)
            {
                return(1);
            }

            if (TrackNumber != other.TrackNumber)
            {
                return(TrackNumber.CompareTo(other.TrackNumber));
            }

            // Same track
            if (other.StartFrame < StartFrame || other.StartFrame > EndFrame)
            {
                // Not overlapping
                return(StartFrame.CompareTo(other.StartFrame));
            }

            // Equal or overlapping
            return(0);
        }
Ejemplo n.º 10
0
        /// <summary>Saves the tag to the specified path.</summary>
        /// <param name="path">The full path of the file.</param>
        private void Save(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            if (VorbisComment.VorbisComment.IsFlac(path))
            {
                VorbisComment.VorbisComment vc = new VorbisComment.VorbisComment(path);
                vc.Title       = Title;
                vc.Artist      = Artist;
                vc.Album       = Album;
                vc.Year        = Year;
                vc.Genre       = Genre;
                vc.TrackNumber = TrackNumber;
                vc.Comment     = Comment;
                vc.Save(path);

                ID3v2Tag.RemoveTag(path);
                ID3v1Tag.RemoveTag(path);
            }
            else
            {
                ID3v2Tag id3v2 = new ID3v2Tag(path);
                id3v2.Title       = Title;
                id3v2.Artist      = Artist;
                id3v2.Album       = Album;
                id3v2.Year        = Year;
                id3v2.Genre       = Genre;
                id3v2.TrackNumber = TrackNumber;

                if (id3v2.CommentsList.Count > 0)
                {
                    id3v2.CommentsList[0].Description = Comment;
                }
                else
                {
                    if (!string.IsNullOrEmpty(Comment))
                    {
                        id3v2.CommentsList.AddNew().Description = Comment;
                    }
                }

                ID3v1Tag id3v1 = new ID3v1Tag(path);
                id3v1.Title      = Title;
                id3v1.Artist     = Artist;
                id3v1.Album      = Album;
                id3v1.Year       = Year;
                id3v1.GenreIndex = GenreHelper.GetGenreIndex(Genre);
                id3v1.Comment    = Comment;
                int trackNumber;
                if (int.TryParse(TrackNumber, out trackNumber))
                {
                    id3v1.TrackNumber = trackNumber;
                }
                else
                {
                    // Handle ##/## format
                    if (TrackNumber.Contains("/"))
                    {
                        if (int.TryParse(TrackNumber.Split('/')[0], out trackNumber))
                        {
                            id3v1.TrackNumber = trackNumber;
                        }
                        else
                        {
                            id3v1.TrackNumber = 0;
                        }
                    }
                    else
                    {
                        id3v1.TrackNumber = 0;
                    }
                }

                id3v2.Save(path);
                id3v1.Save(path);
            }

            Read(path);
        }
Ejemplo n.º 11
0
        private TagData toTagData()
        {
            TagData result = new TagData();

            result.Title              = Title;
            result.Artist             = Artist;
            result.Composer           = Composer;
            result.Comment            = Comment;
            result.Genre              = Genre;
            result.OriginalArtist     = OriginalArtist;
            result.OriginalAlbum      = OriginalAlbum;
            result.GeneralDescription = Description;
            result.Rating             = (Popularity * 5).ToString();
            result.Copyright          = Copyright;
            result.Publisher          = Publisher;
            if (!PublishingDate.Equals(DateTime.MinValue))
            {
                result.PublishingDate = TrackUtils.FormatISOTimestamp(PublishingDate);
            }
            result.AlbumArtist = AlbumArtist;
            result.Conductor   = Conductor;
            if (!Date.Equals(DateTime.MinValue))
            {
                result.RecordingDate = TrackUtils.FormatISOTimestamp(Date);
            }
            result.RecordingYear            = Year.ToString();
            result.Album                    = Album;
            result.TrackNumber              = TrackNumber.ToString();
            result.TrackTotal               = TrackTotal.ToString();
            result.DiscNumber               = DiscNumber.ToString();
            result.DiscTotal                = DiscTotal.ToString();
            result.ChaptersTableDescription = ChaptersTableDescription.ToString();

            result.Chapters = new List <ChapterInfo>();
            foreach (ChapterInfo chapter in Chapters)
            {
                result.Chapters.Add(new ChapterInfo(chapter));
            }

            if (Lyrics != null)
            {
                result.Lyrics = new LyricsInfo(Lyrics);
            }

            foreach (string s in AdditionalFields.Keys)
            {
                result.AdditionalFields.Add(new MetaFieldInfo(MetaDataIOFactory.TAG_ANY, s, AdditionalFields[s]));
            }

            // Detect and tag deleted Additional fields (=those which were in initialAdditionalFields and do not appear in AdditionalFields anymore)
            foreach (string s in initialAdditionalFields)
            {
                if (!AdditionalFields.ContainsKey(s))
                {
                    MetaFieldInfo metaFieldToDelete = new MetaFieldInfo(MetaDataIOFactory.TAG_ANY, s, "");
                    metaFieldToDelete.MarkedForDeletion = true;
                    result.AdditionalFields.Add(metaFieldToDelete);
                }
            }

            result.Pictures = new List <PictureInfo>();
            if (currentEmbeddedPictures != null)
            {
                foreach (PictureInfo targetPic in currentEmbeddedPictures)
                {
                    targetPic.TransientFlag = 0;
                }
            }

            if (initialEmbeddedPictures != null && currentEmbeddedPictures != null)
            {
                foreach (PictureInfo picInfo in initialEmbeddedPictures)
                {
                    // Detect and tag deleted pictures (=those which were in initialEmbeddedPictures and do not appear in embeddedPictures anymore)
                    if (!currentEmbeddedPictures.Contains(picInfo))
                    {
                        PictureInfo picToDelete = new PictureInfo(picInfo);
                        picToDelete.MarkedForDeletion = true;
                        result.Pictures.Add(picToDelete);
                    }
                    else // Only add new additions (pictures identical to initial list will be kept, and do not have to make it to the list, or else a duplicate will be created)
                    {
                        foreach (PictureInfo targetPic in currentEmbeddedPictures)
                        {
                            if (targetPic.Equals(picInfo))
                            {
                                // Compare picture contents
                                targetPic.ComputePicHash();

                                if (targetPic.PictureHash != picInfo.PictureHash)
                                {
                                    // A new picture content has been defined for an existing location
                                    result.Pictures.Add(targetPic);

                                    PictureInfo picToDelete = new PictureInfo(picInfo);
                                    picToDelete.MarkedForDeletion = true;
                                    result.Pictures.Add(picToDelete);
                                }

                                targetPic.TransientFlag = 1;
                            }
                        }
                    }
                }

                if (currentEmbeddedPictures != null)
                {
                    foreach (PictureInfo targetPic in currentEmbeddedPictures)
                    {
                        if (0 == targetPic.TransientFlag) // Entirely new pictures without equivalent in initialEmbeddedPictures
                        {
                            result.Pictures.Add(targetPic);
                        }
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 12
0
        public AlbumTrack(string path)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentNullException("path");
            }

            _path = path;

            if (ID3v2Tag.DoesTagExist(path))
            {
                ID3v2Tag id3v2 = new ID3v2Tag(path);
                DiscNumber  = id3v2.DiscNumber;
                TrackNumber = id3v2.TrackNumber;
                Artist      = id3v2.Artist;
                Title       = id3v2.Title;
                ReleaseDate = id3v2.Year;
                Album       = id3v2.Album;
                Genre       = id3v2.Genre;
                if (id3v2.PictureList != null && id3v2.PictureList.Count == 1)
                {
                    Picture = id3v2.PictureList[0];
                }
            }

            if (ID3v1Tag.DoesTagExist(path))
            {
                ID3v1Tag id3v1 = new ID3v1Tag(path);
                if (string.IsNullOrWhiteSpace(TrackNumber))
                {
                    TrackNumber = string.Format("{0}", id3v1.TrackNumber);
                }
                if (string.IsNullOrWhiteSpace(Artist))
                {
                    Artist = id3v1.Artist;
                }
                if (string.IsNullOrWhiteSpace(Title))
                {
                    Title = id3v1.Title;
                }
                if (string.IsNullOrWhiteSpace(ReleaseDate))
                {
                    ReleaseDate = id3v1.Year;
                }
                if (string.IsNullOrWhiteSpace(Album))
                {
                    Album = id3v1.Album;
                }
                if (string.IsNullOrWhiteSpace(Genre))
                {
                    Genre = GenreHelper.GenreByIndex[id3v1.GenreIndex];
                }
            }

            IAudioFile audioFile = AudioFile.Create(_path, throwExceptionIfUnknown: true);

            Bitrate      = audioFile.Bitrate;
            TotalSeconds = audioFile.TotalSeconds;

            // TODO: APE, Lyrics3

            // TODO: When no tags, try to guess from path and file names
            // TODO: Parse Tracks for TotalTracks
            // TODO: Parse Disc for TotalDiscs

            // Parse track # from TrackNumber including total tracks
            if (!string.IsNullOrWhiteSpace(TrackNumber))
            {
                if (TrackNumber.Contains('/'))
                {
                    TrackNumber = TrackNumber.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries)[0];
                    // TODO: Set total tracks?
                }
            }

            // Parse disc # from DiscNumber including total discs
            if (!string.IsNullOrWhiteSpace(DiscNumber))
            {
                if (DiscNumber.Contains('/'))
                {
                    DiscNumber = DiscNumber.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries)[0];
                    // TODO: Set total discs?
                }
            }
            else
            {
                DiscNumber = "1";
            }
        }
Ejemplo n.º 13
0
 public string TracksToString()
 {
     return("File Name: " + FileName + ", Track #: " + TrackNumber.ToString() + ", Tack Title: " + SongTitle);
 }
Ejemplo n.º 14
0
 public override string ToString()
 {
     return("File Name: " + FileName + ", Track Number: " + TrackNumber.ToString() + ", Song Title: "
            + SongTitle + ", On Album: " + Album + ", Contributing Artists: " + Artists);
 }
Ejemplo n.º 15
0
        public byte[] GetBytes()
        {
            uint WriteChunk(BinaryWriter writer, string tag, string data)
            {
                if (data is null)
                {
                    return(0);
                }

                var bytes = Encoding.Default.GetBytes(data + "\0").ToArray();

                if (bytes.Length % 2 != 0)
                {
                    Array.Resize(ref bytes, bytes.Length + 1);
                    bytes[bytes.Length - 1] = 0;
                }

                writer.Write(FourCC.FromString(tag));
                writer.Write((uint)bytes.Length);
                writer.Write(bytes);

                return((uint)(sizeof(uint) * 2 + bytes.Length));
            }

            using (MemoryStream stream = new MemoryStream())
                using (BinaryWriter writer = new BinaryWriter(stream, Encoding.Default, true)) {
                    writer.Write(FourCC.FromString("LIST"));
                    writer.Write((uint)0);             // ダミー値

                    writer.Write(FourCC.FromString("INFO"));

                    uint len = 0;
                    len += WriteChunk(writer, "IART", Artist);
                    len += WriteChunk(writer, "INAM", Name);
                    len += WriteChunk(writer, "IPRD", Product);
                    len += WriteChunk(writer, "IGNR", Genre);
                    len += WriteChunk(writer, "ICMT", Comment);
                    len += WriteChunk(writer, "ITRK", TrackNumber?.ToString());
                    len += WriteChunk(writer, "ICRD", CreationYear?.ToString());
                    len += WriteChunk(writer, "ISFT", Software);

                    if (len == 0)
                    {
                        // タグ情報なし : データを返さない
                        return(new byte[0]);
                    }

                    // INFO分を加算
                    len += sizeof(uint);

                    if (len % 2 != 0)
                    {
                        len++;
                        writer.Write((byte)0);
                    }

                    // サイズ部分を更新
                    stream.Seek(sizeof(uint), SeekOrigin.Begin);
                    writer.Write(len);


                    return(stream.ToArray());
                }
        }
Ejemplo n.º 16
0
        internal void RemoveTrackNumber(TrackNumber square)
        {
            int key = square.coordinate[0] * 100 + square.coordinate[1];

            TrackNumbers.Remove(key);
        }