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;
QMediaPlayer* soundfile;
To copy to clipboard, switch view to plain text mode
In the constructor Soundfile() i wrote this:
soundfile = new QMediaPlayer(this, QMediaPlayer::LowLatency);
QObject::connect(soundfile,
SIGNAL(positionChanged
(qint64
)),
this,
SLOT(changedPosition
(qint64
)));
soundfile = new QMediaPlayer(this, QMediaPlayer::LowLatency);
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) {
time = time.addMSecs(soundfile->position());
if(p != 0) recordSlider->setValue(p);
changeRecordTime
(QString::number(p
));
recordPositionLabel->setText("Current time: " + time.toString());
}
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());
}
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
Bookmarks