How to play from buffer in Phonon media player?
-
I need to play an audio file present in a USB communication device. I have to read the file from remote path and update a buffer (QBuffer) and simultaneously play the file in Phonon media player where source is set as the buffer. The reading speed is much much higher than the audio file bit rate, i.e., a 10 minutes audio file (wav format: nearly 100 MB) is read with in 1-2 minutes from the remote path. But due to some reason the Phonon player cannot play the file from buffer.
Can anybody please figure out what is going wrong here?
-
You can use QAudioOuput to play audio data. It has two modes of usage. In one case copy data to some buffer and then start QAudioOutput with this buffer. You can use this in case you have all data before start. In other case starting QAudioOutput returns pointer for QIODevice which you can use to write your data while it arriving.
P.S. In later case you can check available space in output buffer and write accordingly.