1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-13 20:39:57 +01:00

* Fixed automatic track progression.

This commit is contained in:
Christian Muehlhaeuser 2011-01-14 16:09:46 +01:00
parent 876a11a1e4
commit 876e3333de
2 changed files with 20 additions and 0 deletions

View File

@ -15,6 +15,7 @@ AudioEngine::AudioEngine()
, m_currentTrackPlaylist( 0 )
, m_queue( 0 )
, m_timeElapsed( 0 )
, m_expectStop( false )
{
qDebug() << "Init AudioEngine";
@ -25,6 +26,7 @@ AudioEngine::AudioEngine()
Phonon::createPath( m_mediaObject, m_audioOutput );
m_mediaObject->setTickInterval( 150 );
connect( m_mediaObject, SIGNAL( stateChanged( Phonon::State, Phonon::State ) ), SLOT( onStateChanged( Phonon::State, Phonon::State ) ) );
connect( m_mediaObject, SIGNAL( tick( qint64 ) ), SLOT( timerTriggered( qint64 ) ) );
}
@ -72,6 +74,7 @@ AudioEngine::stop()
{
qDebug() << Q_FUNC_INFO;
m_expectStop = true;
m_mediaObject->stop();
if ( !m_input.isNull() )
@ -237,6 +240,20 @@ AudioEngine::playItem( PlaylistInterface* playlist, const Tomahawk::result_ptr&
}
void
AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
{
qDebug() << Q_FUNC_INFO << oldState << newState;
if ( oldState == Phonon::PlayingState && newState == Phonon::StoppedState )
{
if ( m_expectStop )
return;
loadNextTrack();
}
}
void
AudioEngine::timerTriggered( qint64 time )
{

View File

@ -26,6 +26,7 @@ public:
~AudioEngine();
unsigned int volume() const { return m_audioOutput->volume() * 100.0; } // in percent
bool isPlaying() const { return m_mediaObject->state() == Phonon::PlayingState; }
bool isPaused() const { return m_mediaObject->state() == Phonon::PausedState; }
/* Returns the PlaylistInterface of the currently playing track. Note: This might be different to the current playlist! */
@ -74,6 +75,7 @@ private slots:
void loadPreviousTrack();
void loadNextTrack();
void onStateChanged( Phonon::State newState, Phonon::State oldState );
void timerTriggered( qint64 time );
void setCurrentTrack( const Tomahawk::result_ptr& result );
@ -91,6 +93,7 @@ private:
Phonon::AudioOutput* m_audioOutput;
unsigned int m_timeElapsed;
bool m_expectStop;
};
#endif // AUDIOENGINE_H