mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 19:45:31 +01:00
Phonon engine works
This commit is contained in:
parent
65ce08ae85
commit
0ba179f54f
@ -1,10 +1,19 @@
|
||||
#include "phononengine.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
PhononEngine::PhononEngine()
|
||||
: media_object_(new Phonon::MediaObject(this)),
|
||||
audio_output_(new Phonon::AudioOutput(Phonon::MusicCategory, this))
|
||||
audio_output_(new Phonon::AudioOutput(Phonon::MusicCategory, this)),
|
||||
state_timer_(new QTimer(this))
|
||||
{
|
||||
Phonon::createPath(media_object_, audio_output_);
|
||||
|
||||
connect(media_object_, SIGNAL(finished()), SLOT(PhononFinished()));
|
||||
connect(media_object_, SIGNAL(stateChanged(Phonon::State,Phonon::State)), SLOT(PhononStateChanged(Phonon::State)));
|
||||
|
||||
state_timer_->setSingleShot(true);
|
||||
connect(state_timer_, SIGNAL(timeout()), SLOT(StateTimeoutExpired()));
|
||||
}
|
||||
|
||||
PhononEngine::~PhononEngine() {
|
||||
@ -46,8 +55,6 @@ void PhononEngine::unpause() {
|
||||
Engine::State PhononEngine::state() const {
|
||||
switch (media_object_->state()) {
|
||||
case Phonon::LoadingState:
|
||||
return Engine::Idle;
|
||||
|
||||
case Phonon::PlayingState:
|
||||
case Phonon::BufferingState:
|
||||
return Engine::Playing;
|
||||
@ -77,3 +84,21 @@ void PhononEngine::seek(uint ms) {
|
||||
void PhononEngine::setVolumeSW(uint percent) {
|
||||
audio_output_->setVolume(qreal(percent) / 100.0);
|
||||
}
|
||||
|
||||
void PhononEngine::PhononFinished() {
|
||||
emit trackEnded();
|
||||
}
|
||||
|
||||
void PhononEngine::PhononStateChanged(Phonon::State new_state) {
|
||||
if (new_state == Phonon::ErrorState) {
|
||||
emit error(media_object_->errorString());
|
||||
}
|
||||
|
||||
// Don't emit the state change straight away
|
||||
state_timer_->start(100);
|
||||
}
|
||||
|
||||
void PhononEngine::StateTimeoutExpired() {
|
||||
qDebug() << state();
|
||||
emit stateChanged(state());
|
||||
}
|
||||
|
@ -3,10 +3,14 @@
|
||||
|
||||
#include "enginebase.h"
|
||||
|
||||
#include <Phonon/MediaObject>
|
||||
#include <Phonon/AudioOutput>
|
||||
#include <phonon/mediaobject.h>
|
||||
#include <phonon/audiooutput.h>
|
||||
|
||||
class QTimer;
|
||||
|
||||
class PhononEngine : public Engine::Base {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PhononEngine();
|
||||
~PhononEngine();
|
||||
@ -30,9 +34,16 @@ class PhononEngine : public Engine::Base {
|
||||
protected:
|
||||
void setVolumeSW( uint percent );
|
||||
|
||||
private slots:
|
||||
void PhononFinished();
|
||||
void PhononStateChanged(Phonon::State new_state);
|
||||
void StateTimeoutExpired();
|
||||
|
||||
private:
|
||||
Phonon::MediaObject* media_object_;
|
||||
Phonon::AudioOutput* audio_output_;
|
||||
|
||||
QTimer* state_timer_;
|
||||
};
|
||||
|
||||
#endif // PHONONENGINE_H
|
||||
|
@ -185,9 +185,9 @@ SOURCES += ../3rdparty/qtsingleapplication/qtlocalpeer.cpp
|
||||
SOURCES += ../3rdparty/qtsingleapplication/qtlockedfile.cpp
|
||||
unix:!fedora-win32-cross:SOURCES += ../3rdparty/qtsingleapplication/qtlockedfile_unix.cpp
|
||||
win32|fedora-win32-cross:SOURCES += ../3rdparty/qtsingleapplication/qtlockedfile_win.cpp
|
||||
win32|fedora-win32-cross:# Hide the console on windows
|
||||
:
|
||||
LIBS += -Wl,-subsystem,windows
|
||||
|
||||
# Hide the console on windows
|
||||
win32|fedora-win32-cross:LIBS += -Wl,-subsystem,windows
|
||||
|
||||
# Installs
|
||||
target.path = $${install_prefix}/bin/
|
||||
|
Loading…
x
Reference in New Issue
Block a user