-rw-r--r-- | library/sound.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/library/sound.cpp b/library/sound.cpp index 602fcf0..1ff3b3f 100644 --- a/library/sound.cpp +++ b/library/sound.cpp @@ -107,6 +107,7 @@ public: filename(Resource::findSound(name)) { loopsleft=0; + ms = WAVsoundDuration(filename); } void playLoop(int loopcnt = -1) @@ -114,7 +115,6 @@ public: // needs server support loopsleft = loopcnt; - int ms = WAVsoundDuration(filename); if ( ms ) startTimer(ms > 50 ? ms-50 : 0); // 50 for latency play(); @@ -123,10 +123,12 @@ public: void timerEvent ( QTimerEvent *e ) { if (loopsleft >= 0) { - if (--loopsleft <= 0) + if ( --loopsleft <= 0 ) { killTimer (e->timerId()); + loopsleft = 0; return; } + } play(); } @@ -138,7 +140,9 @@ public: private: QString filename; int loopsleft; + int ms; }; + #endif Sound::Sound(const QString& name) @@ -158,7 +162,6 @@ Sound::~Sound() void Sound::play() { #ifndef QT_NO_SOUND - d->killTimers(); d->playLoop(1); #endif } @@ -182,6 +185,8 @@ bool Sound::isFinished() const { #ifndef QT_NO_SOUND return d->isFinished(); +#else + return true; #endif } |