X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Falertsound.cpp;h=b6c1fa36ec16b123a4affff05cb62d87ceddb1c5;hb=a06334fdc173e26d116b5625aa50b1236d119dfe;hp=b11f5386101d6797fdffdaf1a06be856dd160a6d;hpb=7fc4c44cca1259b70545aab60cead8cd3ff884ff;p=kitchenalert diff --git a/src/alertsound.cpp b/src/alertsound.cpp index b11f538..b6c1fa3 100644 --- a/src/alertsound.cpp +++ b/src/alertsound.cpp @@ -1,7 +1,7 @@ /************************************************************************** - This file is part of KitchenAlert v.0.09 + This file is part of KitchenAlert - Copyright (C) 2010 Heli Hyvättinen + Copyright (C) 2010-2011 Heli Hyvättinen Kitchen Alert is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,8 +26,9 @@ #include #include -#include +// Initialize static const + const QString AlertSound::defaultsound_ = "/home/opt/KitchenAlert/DoorbellModifiedFinal.mp3"; @@ -35,7 +36,7 @@ AlertSound::AlertSound(QObject *parent) : QObject(parent) { - defaultsound_ = "/opt/KitchenAlert/06capemaycloser_modifiedlouder.mp3"; + QString filename; QSettings settings("KitchenAlert","KitchenAlert"); @@ -43,7 +44,7 @@ AlertSound::AlertSound(QObject *parent) : // settings.clear(); //REMOVE THIS AFTER TESTING!!!!!! bool useDefaultSound = settings.value("UseDefaultSound",true).toBool(); - qDebug() << "In AlertSound constructor UseDefaultSound is " << useDefaultSound; +// qDebug() << "In AlertSound constructor UseDefaultSound is " << useDefaultSound; if (useDefaultSound == true) { filename = defaultsound_; @@ -52,54 +53,46 @@ AlertSound::AlertSound(QObject *parent) : { filename = settings.value("soundfile",defaultsound_).toString(); } - pSound_ = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource(filename)); - //TESTCODE!!! - QList audioOutputDevices = - Phonon::BackendCapabilities::availableAudioOutputDevices(); + pSound_ = new QMediaPlayer; + pSound_->setMedia(QUrl::fromLocalFile(filename)); +} + +AlertSound::~AlertSound() +{ - foreach (Phonon::AudioOutputDevice device, audioOutputDevices) + if (pSound_ != NULL) { - qDebug() << device.name() << device.description(); + delete pSound_; } } void AlertSound::play() { - - //TESTCODE - - Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); - - Phonon::Path path = Phonon::createPath(pSound_, audioOutput); - - audioOutput->setVolumeDecibel(0); - - //TESTCODE ENDS - - pSound_->play(); - qDebug() << "Sound should be played now"; + pSound_->play(); + // qDebug() << "Sound should be played now"; } void AlertSound::stop() { pSound_->stop(); +// qDebug() << pSound_->state(); +// qDebug() << "Sound stopped by AlertSound."; } + + void AlertSound::setSound(QString filename) { - QSettings settings("KitchenAlert","KitchenAlert"); - settings.setValue("UseDefaultSound",false); - settings.setValue("soundfile",filename); - pSound_->setCurrentSource(filename); + + pSound_->setMedia(QUrl::fromLocalFile(filename)); } void AlertSound::setDefaultSound() { - QSettings settings ("KitchenAlert","KitchenAlert"); - settings.setValue("UseDefaultSound",true); - pSound_->setCurrentSource(defaultsound_); + + pSound_->setMedia(QUrl::fromLocalFile(defaultsound_)); }