qbuffer

PyQt5 : QMediaPlayer can't replay audio from QBuffer

别等时光非礼了梦想. 提交于 2021-01-28 06:40:35
问题 I have a QBuffer in RAM with a temporary wav file, and I want to let the user listen it from any point as many times as (s)he want. But, it only allows playing it once, and doesn't allow replaying it. If I play the audio from a file ( QUrl.fromLocalFile ), it can replay it. What's the difference? How to fix it? 1) To play the wav file from RAM I use the following code: data = b"" with open(fname, "rb") as file: data = file.read() buf = QBuffer() buf.setData(data) #For debugging. Real buffer