Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
Accepted Solution

Pause/Sleep in C++

Hello all, I am trying to play audio, wait for the audio to finish and then play anothe piece of audio. I initially used a timer which when it runs out stops the first piece and begins the second, but this is inconvenient just in the way I have things set up, it would be much simpler to have a delay between sounds, is there a way to accomplish this? To just begin the first sound, pause, and resume when the time interval is complete. BB java programming I would use sleep() and I have investigated qt implementations of sleep and wait/notifiy. Does anyone have a recommendation for doing this easily and efficiently? I will continue working on the best method, thanks. 

Developer
soaman
Posts: 849
Registered: ‎03-03-2011
My Device: Z10

Re: Pause/Sleep in C++

Look at http://codeblog.vurdalakov.net/2010/04/how-to-make-qt-thread-sleep.html.

 

You need to subclass QThread and make msleep() method public.

 

Sample code:

class SuperQThread : public QThread
{
   public:
      static void msleep(unsigned long msecs)
      {
         QThread::msleep(msecs);
      }
};

 Then call SuperQThread::msleep(100) to sleep 100 ms.

--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900

Re: Pause/Sleep in C++

Easy solution, thanks very much for this.

Contributor
AlterX
Posts: 46
Registered: ‎08-21-2012
My Device: Blackberry z10 LE

Re: Pause/Sleep in C++


vingilot wrote:

Hello all, I am trying to play audio, wait for the audio to finish and then play anothe piece of audio. I initially used a timer which when it runs out stops the first piece and begins the second, but this is inconvenient just in the way I have things set up, it would be much simpler to have a delay between sounds, is there a way to accomplish this? To just begin the first sound, pause, and resume when the time interval is complete. BB java programming I would use sleep() and I have investigated qt implementations of sleep and wait/notifiy. Does anyone have a recommendation for doing this easily and efficiently? I will continue working on the best method, thanks. 


 

A better solution is to use Phonon that support file audio queue...

Nokia Qt Ambassador
http://www.softairrealfight.net