Logo Search packages:      
Sourcecode: kmess version File versions  Download package

void NowListeningClient::slotUpdate (  )  [slot]

Update the current song

Definition at line 118 of file nowlisteningclient.cpp.

References queryAmarok1(), queryJuk(), queryKsCD(), and queryMprisPlayers().

Referenced by NowListeningClient(), and setEnabled().

{
#ifdef KMESSDEBUG_NOWLISTENINGCLIENT_GENERAL
    kDebug() << "Updating Now Playing status";
#endif

  // Detect changes to reduce signal calls.
  const QString prevArtist( artist_ );
  const QString prevAlbum ( album_ );
  const QString prevTrack ( track_ );
  bool prevPlaying   = playing_;

  // Reset until proven otherwise.
  playing_ = false;

  // Query all applications: the first found stops the search
  if(    queryAmarok1()
      || queryMprisPlayers()
      || queryJuk()
      || queryKsCD()   )
  {
    // Found active media player!

#ifdef KMESSDEBUG_NOWLISTENINGCLIENT_GENERAL
    kDebug() << "found song" << artist_ << "-" << track_ << "(extra info: album=" << album_ << ", playing=" << playing_ << ")";
#endif

    // App found and playing, detect change.
    // Check if player is playing ( and if the song was changed ) or if the player was stopped/paused
    // and now play again.
    if( ( playing_ &&
        (   prevArtist != artist_
        ||  prevAlbum  != album_
        ||  prevTrack  != track_ ) ) || ( ! prevPlaying && playing_ )
      )
    {
#ifdef KMESSDEBUG_NOWLISTENINGCLIENT_GENERAL
      kDebug() << "playing information changed, emitting changedSong().";
#endif
      if( artist_.isEmpty() && album_.isEmpty() && track_.isEmpty() && playing_ == true )
      {
#ifdef KMESSDEBUG_NOWLISTENINGCLIENT_GENERAL
        kDebug() << "any informations about this song..";
#endif
        emit changedSong( QString(), QString(), QString(), false );
      }
      else
      {
        emit changedSong( artist_, album_, track_, playing_ );
      }
    }
  }

  // Emit a signal when the player was stopped.
  if( prevPlaying && ! playing_ )
  {
#ifdef KMESSDEBUG_NOWLISTENINGCLIENT_GENERAL
    kDebug() << "player was stopped, emitting changedSong().";
#endif
    emit changedSong( QString(), QString(), QString(), false );
  }
}


Generated by  Doxygen 1.6.0   Back to index