Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Phonon and queue
Forum Updated to NodeBB v4.3 + New Features

Phonon and queue

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 1.9k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    AlterX
    wrote on last edited by
    #1

    I'm trying to use phonon as sound backend; really I didn't understand how it works!
    My code, just erasing the obviously code, is this:
    @
    function play(QSound file)
    {
    this->media->enqueue(sound);
    this->media->play();
    }
    @
    @
    play("test.wav")
    play("trial.wav")
    @

    So if I put 2 sound clips it works; after hearing those, if I put other two ones, nothing happen, no error and no sounds!

    Is there someone that know how i can do?

    Qt Ambassador
    Real-time cooperative teams: http://www.softairrealfight.net
    Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

    https://codereview.qt-project.org/...

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AlterX
      wrote on last edited by
      #2

      Ok, i've better read documentation...is not so clear, but I've got an intuition...so I've tried and now it's work!

      So, when I put several clips and then I start playing, it works as aspected: play sounds one after other one until queue is not empty; when it ends with all sounds, calling the same code doesn't work as espected because the queue is elaborated only if the media is currently playing.
      So the solution is this:
      @
      void RadioVoicePhononControl::play(QString sound)
      {
      if (this->media->state() == Phonon::PlayingState || this->media->state() == Phonon::LoadingState)
      this->media->enqueue(sound);
      else
      this->media->setCurrentSource(sound);
      }

      void RadioVoicePhononControl::stateChanged(Phonon::State newstate, Phonon::State)
      {
      if (newstate == Phonon::StoppedState) // this state will be set when media has loaded clip
      this->media->play();
      }
      @

      That works because of setCurrentSource(...) that reactivates playing and eventually use the queue.

      Qt Ambassador
      Real-time cooperative teams: http://www.softairrealfight.net
      Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

      https://codereview.qt-project.org/...

      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