void KaraokeWidget::stopKaraoke() { m_karaokeMutex.lock(); KaraokeSong * k = m_karaoke; m_karaoke = 0; m_karaokeMutex.unlock(); // If we stopped our background, start it if ( k ) { if ( k->hasCustomBackground() ) m_background->pause( false ); k->stop(); } delete k; pCurrentState->saveTempData(); }
void KaraokeWidget::stopKaraoke() { Logger::debug("KaraokeWidget::stopKaraoke"); pCurrentState->playerState = CurrentState::PLAYERSTATE_STOPPED; m_karaokeMutex.lock(); KaraokeSong * k = m_karaoke; m_karaoke = 0; m_karaokeMutex.unlock(); // Is anything playing? if ( k == 0 ) return; // If we stopped our background, start it if ( k->hasCustomBackground() ) m_background->pause( false ); k->stop(); delete k; pCurrentState->saveTempData(); Logger::debug("KaraokeWidget::stopKaraoke finished"); }
void KaraokeWidget::playCurrent() { if ( pSongQueue->isEmpty() ) { Logger::debug("KaraokeWidget::playCurrent nothing to play"); pNotification->clearOnScreenMessage(); return; } SongQueueItem current = pSongQueue->current(); // This shouldn't happen if ( current.state == SongQueueItem::STATE_NOT_READY ) abort(); // If current song is not ready yet, show the notification and wait until it is if ( current.state == SongQueueItem::STATE_GETTING_READY ) { Logger::debug("KaraokeWidget::playCurrent want %s play but it is not ready yet", qPrintable( current.file) ); // While we're converting MIDI, ensure other songs are stopped m_karaokeMutex.lock(); if ( m_karaoke ) { m_karaoke->stop(); delete m_karaoke; m_karaoke = 0; } m_karaokeMutex.unlock(); pNotification->setOnScreenMessage( current.stateText() ); QTimer::singleShot( 500, this, SLOT( playCurrent() ) ); return; } Logger::debug("KaraokeWidget::playCurrent %s", qPrintable( current.file) ); pNotification->clearOnScreenMessage(); KaraokeSong * karfile = new KaraokeSong( this, current ); // Pause the background while loading song (prevents GStreamer errors) m_background->pause( true ); try { if ( !karfile->open() ) { // Resume background m_background->pause( false ); delete karfile; return; } } catch ( const QString& ex ) { // Resume background m_background->pause( false ); Logger::error("KaraokeWidget::playCurrent %s: exception %s", qPrintable( current.file), qPrintable(ex) ); MessageBoxAutoClose::critical( "Cannot play file", tr("Cannot play file %1:\n%2") .arg( current.file ) .arg( ex ) ); delete karfile; // Kick the current song out of queue pActionHandler->dequeueSong( current.id ); return; } m_karaokeMutex.lock(); if ( m_karaoke ) { qWarning("BUG: new karaoke is started while the old is not stoppped!"); m_karaoke->stop(); delete m_karaoke; } m_karaoke = karfile; m_karaokeMutex.unlock(); Logger::debug("KaraokeWidget: waiting for the song being loaded"); }