2 * This file is part of jSpeed.
4 * jSpeed is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * jSpeed is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with jSpeed. If not, see <http://www.gnu.org/licenses/>.
19 #include <QtCore/QUrl>
20 #include <QtCore/QDir>
21 #include <QMediaContent>
22 #include "mediaplayer.h"
27 QString const FORMATS[MediaPlayer::FORMAT_COUNT] = {"mp3", "aac", "wav"};
28 QString const LOCAL_SOUND_DIR = ":/resources/sounds/";
31 QMediaPlayer MediaPlayer::player_;
33 bool MediaPlayer::play(QString const& file)
35 QMediaContent media(QUrl::fromLocalFile(file));
42 player_.setMedia(media);
47 void MediaPlayer::getSupportedFormats(QList<QString>& formats)
51 for(int i = 0; i < FORMAT_COUNT; i++)
53 formats.push_back(FORMATS[i]);
57 QString MediaPlayer::getFormatPattern()
61 for(int i = 0; i < FORMAT_COUNT; i++)
63 result += "*." + FORMATS[i] + " ";
66 return result.trimmed();
69 QString MediaPlayer::getSoundDir()
71 return Settings::getDir() + "sounds" + QDir::separator();
74 QString const& MediaPlayer::getLocalSoundDir()
76 return LOCAL_SOUND_DIR;