コード例 #1
0
 public bool Equals(Song other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.AlbumID == AlbumID && other.TrackNum == TrackNum && other.ArtistID == ArtistID &&
         other.EstimateDuration.Equals(EstimateDuration) && Equals(other.CoverArtFilename, CoverArtFilename) &&
         Equals(other.AlbumName, AlbumName) && other.ID == ID && Equals(other.ArtistName, ArtistName) &&
         other.Vote == Vote && Equals(other.Name, Name);
 }
コード例 #2
0
 public SongChangedEventArgs(Song previous, Song current)
 {
     PreviousSong = previous;
     CurrentSong = current;
 }
コード例 #3
0
        private void TimerTick(object sender, EventArgs e)
        {
            var songStatus = GetSongStatus();

            if (songStatus == null || songStatus is DBNull) return;

            var status = (PlayerStatus) int.Parse(songStatus.status.ToString());

            lock (this)
            {
                if (status != Status)
                {
                   if (PlayerStatusChanged != null)
                        PlayerStatusChanged(this, new PlayerStatusEventArgs(Status, status));

                    Status = status;
                }
            }

            var song = songStatus.activeSong;
            /* song object
             * albumID - int
             * trackNum - int
             * artistID - int
             * position - double
             * estimateDuration - int
             * artURL - string / url
             * albumName - string
             * calculatedDuration - double
             * songID - int
             * artistName - string
             * vote - int
             * songName - string
             */

            if (song is DBNull)
            {
                lock (this)
                {
                    if (CurrentSong != null)
                    {
                        if (SongChanged != null)
                            SongChanged(this, new SongChangedEventArgs(CurrentSong, null));
                    }

                    CurrentSong = null;
                }

                Marshal.ReleaseComObject(songStatus);
                return;
            }

            // new definition
            //AlbumID: 3944048
            //AlbumName: "Wasting"
            //ArtistID: 10152
            //ArtistName: "Luminary"
            //CoverArtFilename: "default.png"
            //EstimateDuration: 572000
            //Flags: 0
            //SongID: 24466846
            //SongName: "Wasting (Andy Moor Remix)"
            //autoplayVote: 0
            //context: Object
            //index: 169
            //parentQueueID: "7080204381316276110285"
            //queueSongID: 171
            //source: "recommended"
            //sponsoredAutoplayID: 0

            var newSong = new Song
                        {
                            AlbumID = song.AlbumID,
                            // TrackNum = song.trackNum,
                            ArtistID = song.ArtistID,
                            EstimateDuration = song.EstimateDuration,
                            CoverArtFilename = song.CoverArtFilename,
                            AlbumName = song.AlbumName,
                            ID = song.SongID,
                            ArtistName = song.ArtistName,
                            Vote = song.autoplayVote,
                            Name = song.SongName
                        };

            lock (this)
            {
                if (!newSong.Equals(CurrentSong))
                {
                    if (SongChanged != null)
                        SongChanged(this, new SongChangedEventArgs(CurrentSong, newSong));

                    CurrentSong = newSong;
                }
            }

            Marshal.ReleaseComObject(songStatus);
        }