private void meta_sync(int a, int b, int c, IntPtr d) { System.Diagnostics.Debug.WriteLine("Meta Sync: " + a + " " + b + " " + c + " " + d.ToInt32()); var tgs = new TAG_INFO(); bool result = BassTags.BASS_TAG_GetFromURL(_stream, tgs); if (result) { System.Diagnostics.Debug.WriteLine(tgs.ToString()); } _currentSong = new SongInfo(_currentSong.FileName, tgs.artist, tgs.album, tgs.title, 0, 0, 0, tgs.genre, "", false); _playingStream = true; if (AudioscrobblerEnabled && !string.IsNullOrEmpty(_currentSong.Title) && !string.IsNullOrEmpty(_currentSong.Artist)) { var req = new AudioscrobblerRequest(); req.Username = AudioscrobblerUserName; req.Password = AudioscrobblerPassword; req.SubmitTrack(_currentSong); } OnSongOpened(); }
public Player(int deviceNumber) { _playlist = new Playlist(this); InitBassLibrary(deviceNumber); _timer = new System.Timers.Timer(100); _timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); _meta_proc = new SYNCPROC(meta_sync); void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { BASSActive active = Bass.BASS_ChannelIsActive(_stream); if (active == BASSActive.BASS_ACTIVE_PLAYING) { _position = Bass.BASS_ChannelBytes2Seconds(_stream, Bass.BASS_ChannelGetPosition(_stream)); PositionChanged(this, EventArgs.Empty); if (Convert.ToInt32(_lastPosition) != Convert.ToInt32(_position)) { OnPositionDescriptionChanged(); _lastPosition = _position; } _timerTicks += 100; if (_timerTicks >= 1000) { _timerTicks = 0; _secondsPlayed++; if (_secondsPlayed >= SecondsBeforeUpdatePlayCount && !_playCountUpdated) { System.Diagnostics.Debug.WriteLine(SecondsBeforeUpdatePlayCount.ToString() + " seconds, updating play count"); _playCountUpdated = true; if (_lib != null) { _lib.UpdatePlayCount(_currentSong.FileName); if (AudioscrobblerEnabled) { var req = new AudioscrobblerRequest(); req.Username = AudioscrobblerUserName; req.Password = AudioscrobblerPassword; req.SubmitTrack(_currentSong); } } } } } else if (active == (int)BASSActive.BASS_ACTIVE_STOPPED) { if (!_playCountUpdated) { if (Convert.ToInt32(this.CurrentSong.Duration) <= SecondsBeforeUpdatePlayCount) { System.Diagnostics.Debug.WriteLine("Didn't reach " + SecondsBeforeUpdatePlayCount.ToString() + " seconds because song finished, updating play count"); _playCountUpdated = true; if (_lib != null) { _lib.UpdatePlayCount(_currentSong.FileName); } } } _timer.Stop(); this.State = PlayerState.Stopped; OnSongFinished(); if (_autoTrackAdvance) { if (_repeatCurrentTrack) { Stop(); Play(); } else { Next(); } } } } }