mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-16 14:52:15 +08:00
4012d181e1
date: 2024-03-17T10:14:38 master commit: 7e9a909e0e57ecb31df4c87c5b9a06b1204fd034
31 lines
741 B
C++
31 lines
741 B
C++
#include <QApplication>
|
|
#include <QSoundEffect>
|
|
#include <QTimer>
|
|
#include <QDebug>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
QApplication a(argc, argv);
|
|
|
|
QTimer::singleShot(0, [=]{
|
|
QSoundEffect s;
|
|
const char *vol = getenv("VOLUME");
|
|
s.setVolume(vol ? atof(vol) : 1.0);
|
|
for (int i = 1; i < argc; i++) {
|
|
QString fn = argv[i];
|
|
qDebug() << "playing" << fn;
|
|
|
|
QEventLoop loop;
|
|
s.setSource(QUrl::fromLocalFile(fn));
|
|
QEventLoop::connect(&s, &QSoundEffect::loadedChanged, &loop, &QEventLoop::quit);
|
|
loop.exec();
|
|
s.play();
|
|
QEventLoop::connect(&s, &QSoundEffect::playingChanged, &loop, &QEventLoop::quit);
|
|
loop.exec();
|
|
}
|
|
QCoreApplication::exit();
|
|
});
|
|
|
|
return a.exec();
|
|
}
|