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. Phonon and bufferStatus signal.
Forum Updated to NodeBB v4.3 + New Features

Phonon and bufferStatus signal.

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 3.1k 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.
  • O Offline
    O Offline
    Overflowz
    wrote on last edited by
    #1

    Hi, I'm having problem with Phonon and progress bar. I want to increase progress bar while music plays but bufferStatus signal fails I think. Here's code:

    [code] Phonon::MediaObject *music = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource("C:/Users/User/Desktop/test.mp3"));
    ui->progressBar->setRange(0, 100);
    ui->progressBar->setValue(0);
    connect(music, SIGNAL(bufferStatus(int)), ui->progressBar, SLOT(setValue(int)));
    music->play();[/code]

    Music plays well, but progress bar is always zero. What's problem?!

    1 Reply Last reply
    0
    • I Offline
      I Offline
      ilean
      wrote on last edited by
      #2

      I'm not sure... but I think you're using the wrong signal.
      bufferStatus is correct when you use phonon in BufferingState

      I think you shall use tick() signal.

      1 Reply Last reply
      0
      • O Offline
        O Offline
        Overflowz
        wrote on last edited by
        #3

        QObject::connect: Incompatible sender/receiver arguments
        Phonon::MediaObject::tick(qint64) --> QProgressBar::setValue(int)

        :(

        1 Reply Last reply
        0
        • O Offline
          O Offline
          Overflowz
          wrote on last edited by
          #4

          I did some tests, but neither tick(qint64) or bufferStatus(int) never gets emitted. Is it a bug? Am I initializing it wrong?

          1 Reply Last reply
          0
          • I Offline
            I Offline
            ilean
            wrote on last edited by
            #5

            You're missing something.

            I've just compiled Phonon demo and progres bar works fine (on Qt 4.8)

            I didn't see any special configuration to mediaObject to emit this signal.
            Take care using the same var type (int64 in your slot)

            Take a look to Phonon example.

            1 Reply Last reply
            0
            • O Offline
              O Offline
              Overflowz
              wrote on last edited by
              #6

              Hi, documentation says if you want to use player with progress bar, use bufferStatus signal. Neither works for me.. Look at this, it doesn't work. Can you post code that worked for you? Thank you.

              [code]MainWindow::MainWindow(QWidget *parent) :
              QMainWindow(parent),
              ui(new Ui::MainWindow)
              {
              ui->setupUi(this);
              Phonon::MediaObject *music = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource("C:/Users/User/Desktop/test.mp3"));
              ui->progressBar->setRange(0, 100);
              ui->progressBar->setValue(0);
              connect(music, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
              music->play();
              }

              void MainWindow::tick(qint64 x)
              {
              ui->label->setText(QString::number(x)); //set label text, for test..
              }[/code]

              1 Reply Last reply
              0
              • I Offline
                I Offline
                ilean
                wrote on last edited by
                #7

                Ok, I'd found it.

                In demo code doesn't configure it, but it's necesary to configure tickInterval property as it is 0 by default.

                Just include music.setTickInterval(1) and will work.

                look:

                @#include "MainWindow.h"
                #include "ui_MainWindow.h"

                #include <phonon>

                MainWindow::MainWindow(QWidget *parent) :
                QMainWindow(parent),
                ui(new Ui::MainWindow)
                {
                ui->setupUi(this);
                pb = ui->progressBar;
                pb->setFormat("%v/%m (%p%)");
                Phonon::MediaObject *music = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource("C:/Users/Public/Music/Sample Music/Kalimba.mp3"));
                music->setTickInterval(200);
                connect(music, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
                connect(music, SIGNAL(totalTimeChanged(qint64)), this, SLOT(maxTime(qint64)));
                music->play();
                }

                MainWindow::~MainWindow()
                {
                delete ui;
                }

                void MainWindow::tick(qint64 x)
                {
                pb->setValue(x);
                }

                void MainWindow::maxTime(qint64 x)
                {
                pb->setMaximum(x);
                }@

                1 Reply Last reply
                0
                • O Offline
                  O Offline
                  Overflowz
                  wrote on last edited by
                  #8

                  Yay, thank you! It works now!
                  Btw, why setTickInterval(200) ?

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    ilean
                    wrote on last edited by
                    #9

                    200 ms. is an arbitrary interval :P
                    If you want more precision, reduce it.

                    1 Reply Last reply
                    0
                    • O Offline
                      O Offline
                      Overflowz
                      wrote on last edited by
                      #10

                      Thank you! You helped me a lot!

                      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