QMediaPlayer: position update interrupts sound



  • Hello,

    i am programming a software which includes playing a sound file.

    Everytime when the signal positionChanged(qint64) is emitted, my position slider should update the current position of the sound file. This works fine, but everytime when this happens (every second) the sound interrupts for a moment.

    In my class Soundfile i create a pointer of QMediaPlayer named soundfile.

    QMediaPlayer* soundfile;
    

    In the constructor Soundfile() i wrote this:

    soundfile = new QMediaPlayer(this, QMediaPlayer::LowLatency);
    QObject::connect(soundfile, SIGNAL(positionChanged(qint64)), this, SLOT(changedPosition(qint64)));
    

    The slot changedPosition in the class Soundfile is this:

    void Soundfile::changedPosition(qint64 p) {
    QTime time(0,0,0,0);
    time = time.addMSecs(soundfile->position());

    if(p != 0) recordSlider->setValue(p);
    changeRecordTime(QString::number(p));
    recordPositionLabel->setText("Current time: " + time.toString());
    

    }

    (the rest is updating the current time label)

    Is there any problem why it could interrupting playing the sound file?

    I hope someone has an idea.

    With best regards,
    Christian


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Do you have anything else that is connected to this QMediaPlayer ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.