Example #1
0
 /// <summary>
 /// Save song to the stream
 /// </summary>
 /// <param name="bw">Current stream</param>
 /// <param name="song">Song</param>
 public static void SaveSong(BinaryWriter bw, Song song)
 {
     bw.Write(song.ID);
     bw.Write(song.Name);
     bw.Write(song.Length.Item1);
     bw.Write(song.Length.Item2);
     bw.Write(song.Artist);
     bw.Write((byte)song.Genre);
     bw.Write(song.Rating);
 }
Example #2
0
        /// <summary>
        /// Add song to the playlist
        /// </summary>
        /// <param name="song">Song</param>
        public void AddSong(Song song)
        {
            if (Songs.Find(x => x.ID == song.ID) == null)
            {
                Songs.Add(song);
                Tuple<byte, byte> temp = new Tuple<byte, byte>((byte)(Length.Item1 + song.Length.Item1), (byte)(Length.Item2 + song.Length.Item2));
                if (temp.Item2 >= 60)
                    Length = new Tuple<byte, byte>((byte)(temp.Item1 + 1), (byte)(temp.Item2 - 60));
                else Length = temp;

                double rating = Songs.Average(x => x.Rating);
                Rating = rating;
            }
        }