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. QMediaPlayer: position update interrupts sound
Forum Updated to NodeBB v4.3 + New Features

QMediaPlayer: position update interrupts sound

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 647 Views 2 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.
  • C Offline
    C Offline
    ChristianH
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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