| 6 | #include "ChessVoice.h" |
| 7 | |
| 8 | ChessVoice::ChessVoice(QObject *parent) |
| 9 | : QObject(parent) |
| 10 | { |
| 11 | // 注意:资源路径用 qrc 前缀(已在资源文件 .qrc 中配置) |
| 12 | m_win.setSource(QUrl(QStringLiteral("qrc:/sound/WinSound.wav"))); |
| 13 | m_select.setSource(QUrl(QStringLiteral("qrc:/sound/selectChess.wav"))); |
| 14 | m_move.setSource(QUrl(QStringLiteral("qrc:/sound/moveChess.wav"))); |
| 15 | m_eat.setSource(QUrl(QStringLiteral("qrc:/sound/eatChess.wav"))); |
| 16 | m_back.setSource(QUrl(QStringLiteral("qrc:/sound/backChess.wav"))); |
| 17 | m_general.setSource(QUrl(QStringLiteral("qrc:/sound/generalSound.wav"))); |
| 18 | |
| 19 | // 设置音量(0.0 至 1.0) |
| 20 | m_win.setVolume(1.0f); |
| 21 | m_select.setVolume(1.0f); |
| 22 | m_move.setVolume(1.0f); |
| 23 | m_eat.setVolume(1.0f); |
| 24 | m_back.setVolume(1.0f); |
| 25 | m_general.setVolume(1.0f); |
| 26 | |
| 27 | // 可选:预加载或设置 loopCount 等,下面为一次播放 |
| 28 | m_win.setLoopCount(1); |
| 29 | m_select.setLoopCount(1); |
| 30 | m_move.setLoopCount(1); |
| 31 | m_eat.setLoopCount(1); |
| 32 | m_back.setLoopCount(1); |
| 33 | m_general.setLoopCount(1); |
| 34 | } |
| 35 | |
| 36 | ChessVoice::~ChessVoice() |
| 37 | { |
nothing calls this directly
no outgoing calls
no test coverage detected