Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Play several sounds in the same time.
QtWS25 Last Chance

Play several sounds in the same time.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sil20
    wrote on last edited by
    #1

    Hello,
    I am currently developping a QML application, and in a plugin I would like to play a sound (wave file).
    But there are several instances and only one sound can be played at a time. I am using Qsound to do this.

    @ QString lstmp=getenv("PROJECT");lstmp+="\recorder4.wav";
    if(!QSound::isAvailable()) qWarning("QMLCanvas error :QSound not available on this plateform");
    QSound::play(lstmp);@

    I did it with Phonon. But I tried to overload the system, ans send it every 100ms so I have the following error comming:
    QThread::start: Failed to create thread (Code d?acc?s non valide.)

    How can I test the availability of the system?

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      can you try the following please (instead using the the static method):
      @
      QSound first("first.wav");
      first.play();
      QSound second("second.wav");
      second.play();
      @

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sil20
        wrote on last edited by
        #3

        Hi again,
        using Phonon, I face a delemma:

        either I pu a local instance in the method called every time I needa sound to be played and the instance seems dynamically allocated, and my process size increase in memorry:
        @ //-------------------------------------
        //Local Sounds
        Phonon::MediaObject *lTmpmusic =
        Phonon::createPlayer(Phonon::MusicCategory,
        Phonon::MediaSource(lstmp));
        lTmpmusic->play();@

        Or I use a member in my class, but only the first sound is played
        @if(music!=NULL)
        {
        if(music->state()==Phonon::PlayingState)
        music->stop();
        music->play();
        }@

        Is there a way to have a self destructive instance when the sound is finished playing ?
        Or how to "restart" playing the sound when only one member instance is avialable?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved