我正在尝试制作基于 pyqt5 的音频播放器。但是阅读站点包中的示例并在 PyQt4 开始时访问 QAudioOutput 奇怪的峰值声音我无法向前迈出一步,似乎没有音频输出。在此先感谢,这是我当前的代码(python3.3)
import sys
from PyQt5 import QtGui, QtCore, QtWidgets, QtMultimedia
class Window(QtWidgets.QWidget):
def __init__(self, parent = None):
QtWidgets.QWidget.__init__(self, parent)
format = QtMultimedia.QAudioFormat()
format.setSampleRate(44100)
format.setSampleSize(16)
format.setChannelCount(1)
format.setCodec("audio/wav")
format.setByteOrder(QtMultimedia.QAudioFormat.LittleEndian)
format.setSampleType(QtMultimedia.QAudioFormat.SignedInt)
self.output = QtMultimedia.QAudioOutput(QtMultimedia.QAudioDeviceInfo.defaultOutputDevice(), format, self)
self.file=QtCore.QFile()
self.file.setFileName("data/voicemail/99dc6d529c0c5d6b2ec5cda7b26cc1bb9af58bd4774d161f66186f62bf3093cd.wav")
self.file.open(QtCore.QIODevice.ReadOnly)
self.file.seek(44)
self.output.start(self.file)
#self.file.close()
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())