soundplayer.h 828 Bytes
#ifndef SOUNDPLAYER_H
#define SOUNDPLAYER_H

#include <QObject>
#include <QSound>
#include <QSoundEffect>
#include <QThread>
#include <QMap>

class SoundPlayWorker : public QObject
{
    Q_OBJECT
public:
    explicit SoundPlayWorker();

public slots:
    void play(const QString &filename);
    void playClick();

private:
    QMap<QString, QSound *> map;
    QSound *current;
    QSoundEffect *click;
};

class SoundPlayer : public QObject
{
    Q_OBJECT

    explicit SoundPlayer();
    void play(const QString &filename);
    void emitClick();

    static SoundPlayer *instance;

public:
    static void playClick();
    static void playStart();
    static void playStop();
    static void playError1();
    static void playError2();

signals:
    void operate(const QString &);
    void click();
};

#endif // SOUNDPLAYER_H