X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Falertsound.cpp;h=b6c1fa36ec16b123a4affff05cb62d87ceddb1c5;hb=383c3ee723d6ff55d01bcc83a8f98fab1b32cc03;hp=94470b08074e99b7823a63a53c8c75064c938e48;hpb=8c81978843d45998b02e3556bb4e326c37dac723;p=kitchenalert diff --git a/src/alertsound.cpp b/src/alertsound.cpp index 94470b0..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 @@ -27,13 +27,16 @@ #include #include +// Initialize static const + const QString AlertSound::defaultsound_ = "/home/opt/KitchenAlert/DoorbellModifiedFinal.mp3"; + AlertSound::AlertSound(QObject *parent) : QObject(parent) { - defaultsound_ = "/opt/KitchenAlert/06capemaycloser_modifiedlouder.mp3"; + QString filename; QSettings settings("KitchenAlert","KitchenAlert"); @@ -41,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_; @@ -50,33 +53,46 @@ AlertSound::AlertSound(QObject *parent) : { filename = settings.value("soundfile",defaultsound_).toString(); } - pSound_ = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource(filename)); + + + + pSound_ = new QMediaPlayer; + pSound_->setMedia(QUrl::fromLocalFile(filename)); } -void AlertSound::play() +AlertSound::~AlertSound() { - pSound_->play(); - qDebug() << "Sound should be played now"; + if (pSound_ != NULL) + { + delete pSound_; + } +} + +void AlertSound::play() +{ + 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_)); }