Extend AudioPlayer so that it gives info about if something is playing at the moment or not

Reviewed by Jaydeep Solanki

REVIEW: 114019
remotes/origin/KDE/4.13
Egor Matirov 12 years ago committed by Albert Astals Cid
parent 34c9c7fc8a
commit f98f55db9d
  1. 10
      core/audioplayer.cpp
  2. 23
      core/audioplayer.h
  3. 1
      core/audioplayer_p.h

@ -85,7 +85,7 @@ public:
AudioPlayerPrivate::AudioPlayerPrivate( AudioPlayer * qq )
: q( qq )
: q( qq ), m_state( AudioPlayer::StoppedState )
{
QObject::connect( &m_mapper, SIGNAL(mapped(int)), q, SLOT(finished(int)) );
}
@ -173,6 +173,7 @@ bool AudioPlayerPrivate::play( const SoundInfo& si )
QObject::connect( data->m_mediaobject, SIGNAL(finished()), &m_mapper, SLOT(map()) );
kDebug(OkularDebug) << "PLAY";
data->play();
m_state = AudioPlayer::PlayingState;
}
return valid;
}
@ -181,6 +182,7 @@ void AudioPlayerPrivate::stopPlayings()
{
qDeleteAll( m_playing );
m_playing.clear();
m_state = AudioPlayer::StoppedState;
}
void AudioPlayerPrivate::finished( int id )
@ -201,6 +203,7 @@ void AudioPlayerPrivate::finished( int id )
m_mapper.removeMappings( it.value()->m_mediaobject );
delete it.value();
m_playing.erase( it );
m_state = AudioPlayer::StoppedState;
}
kDebug(OkularDebug) << "finished," << m_playing.count();
}
@ -248,4 +251,9 @@ void AudioPlayer::stopPlaybacks()
d->stopPlayings();
}
AudioPlayer::State AudioPlayer::state() const
{
return d->m_state;
}
#include "audioplayer.moc"

@ -32,6 +32,23 @@ class OKULAR_EXPORT AudioPlayer : public QObject
Q_OBJECT
public:
/**
* The state of AudioPlayer
* @since 0.19 (KDE 4.13)
*/
enum State
{
/**
* The AudioPlayer is playing a audio file.
*/
PlayingState,
/**
* The AudioPlayer isn't playing a audio file.
*/
StoppedState
};
~AudioPlayer();
/**
@ -50,6 +67,12 @@ class OKULAR_EXPORT AudioPlayer : public QObject
*/
void stopPlaybacks();
/**
* Return state of sound (playing/stopped)
* @since 0.19 (KDE 4.13)
*/
State state() const;
private:
AudioPlayer();

@ -42,6 +42,7 @@ public:
QHash< int, PlayData * > m_playing;
QSignalMapper m_mapper;
KUrl m_currentDocument;
AudioPlayer::State m_state;
};
}

Loading…
Cancel
Save