I am trying to use the QAudioProbe
class with QMediaPlayer
but I can't seem to get it working. As suggested here, I'm using it to create an audio visualizer. I had the following:
QMediaPlayer* player = new QMediaPlayer;
QAudioProbe* probe = new QAudioProbe;
// note: processBuffer() is a custom slot
connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)),
this, SLOT(processBuffer(QAudioBuffer)));
if(!probe->setSource(player))
cout << "Source for AudioProbe not set!" << endl;
Whenever I tried to set player
as the source for probe
, it returned false
.
Next, I tried setting the media for player
before setting it as the source for probe
.
player->setMedia(...);
if(!probe->setSource(player))
cout << "Source for AudioProbe not set!" << endl;
player->play();
Still returns false. I've been looking online for a while now but no luck. Any suggestions to get this working?
Suggestions for other methods of receiving data from QMediaPlayer
are also welcomed. However, I would prefer to use Qt classes.