Пример #1
0
void LastFmService::init()
{
    m_currentTrack    = 0;
    
    bool enable = SETTINGS()->_useLastFmScrobbler;
    Debug::debug() << "  [LastFmService] init enable " << enable;
    
    disconnect(Engine::instance(), 0,this, 0);

    /*  load settings */
    QSettings settings(UTIL::CONFIGFILE,QSettings::IniFormat,this);
    settings.beginGroup("Scrobbler");

    LastFm::GLOBAL::username      = settings.value("username", QString()).toString();
    LastFm::GLOBAL::session_key   = settings.value("key", QString()).toString();
    LastFm::GLOBAL::api_key       = "b3717637c18071e1619e92ee2c3eb0f8";
    LastFm::GLOBAL::secret_key    = "8192599d44d34b27c520d597d34f3714";
    settings.endGroup();
    
    if( enable && isAuthenticated() ) 
    {
       connect(Engine::instance(), SIGNAL(engineStateChanged()), this, SLOT(slot_state_changed()));
       connect(Engine::instance(), SIGNAL(mediaChanged()), this, SLOT(slot_track_changed()));
    }
    
    /* change status for send love action */
    ACTIONS()->value(LASTFM_LOVE)->setEnabled(enable);
    ACTIONS()->value(LASTFM_LOVE_NOW_PLAYING)->setEnabled(enable);    
}
Пример #2
0
void MainWindow::engineHasVideoChanged( bool hasVideo )
{
    Q_UNUSED(hasVideo);

    qDebug() << "hasVideo changed" << hasVideo;
    if( TheStream::hasVideo() ) {
        if( m_mainView->indexOf(engine()) == -1 )
            m_mainView->addWidget(engine());
        m_mainView->setCurrentWidget(engine());
        m_currentWidget = engine();

        // Fake change of state to trigger a re-evaluation of enabled actions.
        // The video state might have changed *after* a state change (e.g. in Phonon-VLC)
        // in which case the video related menu actions will not be enabled until
        // a new state change occurs. By forcing a fake state change we can work around this.
        engineStateChanged(videoWindow()->state());
    } else if (engine()->isActiveState()) {
        m_audioView->setupAnalyzer();
        m_mainView->setCurrentWidget(m_audioView);
        m_currentWidget = m_audioView;
    }

    if (TheStream::hasVideo()) {
        inhibitPowerSave();
        // Assumption: since we have no playlist the only way to release suppression
        // is through going into stopped state. This also means that should there
        // ever be a playlist playing video and then audio will possibly not
        // release video specific inhibitions.
    }
}
Пример #3
0
/* ---------------------------------------------------------------------------*/
void EnginePhonon::slot_on_phonon_state_changed(Phonon::State newState, Phonon::State oldState)
{
    //Debug::warning() << "[EnginePhonon] -> slot_on_phonon_state_changed : " << newState ;
    if(newState == oldState)
      return;

    switch (newState) {
      case Phonon::LoadingState:  m_current_state = ENGINE::STOPPED; break;

      case Phonon::StoppedState:  m_current_state = ENGINE::STOPPED; break;

      case Phonon::PlayingState:  m_current_state = ENGINE::PLAYING; break;

      case Phonon::BufferingState:  break;

      case Phonon::PausedState:   m_current_state = ENGINE::PAUSED;  break;

      case Phonon::ErrorState:    m_current_state = ENGINE::ERROR;   break;

      default:break;
    }

    if(m_old_state != m_current_state)
    {
      if(m_current_state != ENGINE::STOPPED)
      {
        //Debug::debug() << "[EnginePhonon] -> engineStateChanged :" << stateToString(m_current_state);
        emit engineStateChanged();
      }
      else if(!m_currentMediaItem)
      {
        //Debug::debug() << "[EnginePhonon] -> engineStateChanged :" << stateToString(m_current_state);
        emit engineStateChanged();
      }

      m_old_state = m_current_state;
    }
}