我想在网络上使用 PyQt5 的 QWebEngineView 播放音频。这是我的代码:
import sys
from PyQt5 import QtWebEngineWidgets, QtWidgets
if __name__ == '__main__':
app = QtWidgets.QApplication([])
view = QtWebEngineWidgets.QWebEngineView()
view.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.PluginsEnabled, True)
view.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.JavascriptEnabled, True)
html = '''
<html>
<audio id="pron" src="http://static.sfdict.com/staticrep/dictaudio/A06/A0612000.mp3"></audio>
<button onclick="document.getElementById('pron').play()">Play!</button>
</html>'''
view.setHtml(html)
view.resize(250, 150)
view.move(300, 300)
view.show()
sys.exit(app.exec_())
但是当我点击Play
按钮时,音频不播放。我怎么了?