pyqt播放音频
pyqt播放音频
from PyQt5.QtCore import QUrl from PyQt5.QtMultimedia import QMediaPlayer from PyQt5.QtWidgets import QApplication import sys app = QApplication(sys.argv) # Create a QMediaPlayer object player = QMediaPlayer() # Set the media to play url = QUrl.fromLocalFile("path/to/file.mp3") player.setMedia(url) # Play the media player.play() # Exit the application when the media has finished playing player.stateChanged.connect(lambda state: app.quit()) # Run the application sys.exit(app.exec_())
#######################
QQ 3087438119