Results 1 to 2 of 2

Thread: QMediaPlayer: positionChanged() Signal interrupts sound

  1. #1
    Join Date
    Mar 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default QMediaPlayer: positionChanged() Signal 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.

    Qt Code:
    1. QMediaPlayer* soundfile;
    To copy to clipboard, switch view to plain text mode 

    In the constructor Soundfile() i wrote this:

    Qt Code:
    1. soundfile = new QMediaPlayer(this, QMediaPlayer::LowLatency);
    2. QObject::connect(soundfile, SIGNAL(positionChanged(qint64)), this, SLOT(changedPosition(qint64)));
    To copy to clipboard, switch view to plain text mode 

    The slot changedPosition in the class Soundfile is this:

    void Soundfile::changedPosition(qint64 p) {
    Qt Code:
    1. QTime time(0,0,0,0);
    2. time = time.addMSecs(soundfile->position());
    3.  
    4. if(p != 0) recordSlider->setValue(p);
    5. changeRecordTime(QString::number(p));
    6. recordPositionLabel->setText("Current time: " + time.toString());
    7. }
    To copy to clipboard, switch view to plain text mode 

    (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

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QMediaPlayer: positionChanged() Signal interrupts sound

    Have you checked how long the slot needs to execute?
    If it exceeds the time the player has buffered data for, then it can't play any further until the slot returns.

    Cheers,
    _

Similar Threads

  1. QMediaplayer Sound file problem
    By digimonkey in forum Newbie
    Replies: 1
    Last Post: 4th February 2018, 06:33
  2. QMediaplayer Sound status
    By digimonkey in forum Qt Programming
    Replies: 0
    Last Post: 16th March 2015, 09:56
  3. QMediaPlayer Sound not working in other PCs
    By digimonkey in forum Qt Programming
    Replies: 2
    Last Post: 13th March 2015, 05:07
  4. QMediaPlayer repeat sound
    By alenn.masic in forum Qt Programming
    Replies: 0
    Last Post: 21st February 2013, 14:46
  5. Qt - catching interrupts
    By rishid in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2008, 14:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.