| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2009 by The qGo Project * |
| 3 | * * |
| 4 | * This file is part of qGo. * |
| 5 | * * |
| 6 | * qGo is free software: you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, see <http://www.gnu.org/licenses/> * |
| 18 | * or write to the Free Software Foundation, Inc., * |
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | |
| 23 | #include "audio/audio.h"cxx . . $ `<file>/src/audio/audio.h`/ |
| 24 | #include <QDir> |
| 25 | #include <defines.h>cxx . . $ `<file>/src/defines.h`/ |
| 26 | #include <QtMultimedia/QMediaPlayer> |
| 27 | |
| 28 | Soundcxx . . $ Sound#::Soundcxx . . $ Sound#Sound(6caa6e6871ecf3b).(const QStringcxx . . $ QString# &filename, QObjectcxx . . $ QObject# *parent, int delay_msec) |
| 29 | : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent), delaycxx . . $ Sound#delay.(delay_msec) |
| 30 | { |
| 31 | playercxx . . $ Sound#player. = new QMediaPlayercxx . . $ QMediaPlayer#QMediaPlayer(7f3ad1f5f49905dc).; |
| 32 | if (QDircxx . . $ QDir#QDir(3520e46b33348bf6).().existscxx . . $ QDir#exists(f3b39adf77d9c36c).(SOUND_PATH_PREFIXcxx . . $ `src/defines.h:223:13`! +cxx . . $ operator+(c75c3ae4eb9af1a8). filename)) |
| 33 | playercxx . . $ Sound#player.->setMediacxx . . $ QMediaPlayer#setMedia(51836691532b0917).(QMediaContentcxx . . $ QMediaContent#(QUrlcxx . . $ QUrl#::fromLocalFilecxx . . $ QUrl#fromLocalFile(daf4b0201622af21).(QDircxx . . $ QDir#QDir(3520e46b33348bf6).().absoluteFilePathcxx . . $ QDir#absoluteFilePath(5555d9024dcf93fb).(SOUND_PATH_PREFIXcxx . . $ `src/defines.h:223:13`! +cxx . . $ operator+(c75c3ae4eb9af1a8). filename)))); |
| 34 | nextSoundcxx . . $ Sound#nextSound. =cxx . . $ QTime#`operator=`(370b645f04941e62). QTimecxx . . $ QTime#::currentTimecxx . . $ QTime#currentTime(bd2fc2b92108c576).(); |
| 35 | } |
| 36 | |
| 37 | Soundcxx . . $ Sound#::~cxx . . $ Sound#`~Sound`(ced63f7c635d850d).Soundcxx . . $ Sound#() |
| 38 | { |
| 39 | delete playercxx . . $ Sound#player.; |
| 40 | } |
| 41 | |
| 42 | void Soundcxx . . $ Sound#::playcxx . . $ Sound#play(49f6e7a06ebc5aa8).(void) |
| 43 | { |
| 44 | // Do not play the same sound too often (by default every 250 ms) |
| 45 | if (QTimecxx . . $ QTime#::currentTimecxx . . $ QTime#currentTime(bd2fc2b92108c576).() <cxx . . $ QTime#`operator<`(1610574c25194847). nextSoundcxx . . $ Sound#nextSound.) |
| 46 | return; |
| 47 | |
| 48 | nextSoundcxx . . $ Sound#nextSound. =cxx . . $ QTime#`operator=`(370b645f04941e62). QTimecxx . . $ QTime#::currentTimecxx . . $ QTime#currentTime(bd2fc2b92108c576).(); |
| 49 | nextSoundcxx . . $ Sound#nextSound. =cxx . . $ QTime#`operator=`(370b645f04941e62). nextSoundcxx . . $ Sound#nextSound..addMSecscxx . . $ QTime#addMSecs(902e6118dfa1a226).(delaycxx . . $ Sound#delay.); |
| 50 | playercxx . . $ Sound#player.->playcxx . . $ QMediaPlayer#play(49f6e7a06ebc5aa8).(); |
| 51 | } |