Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 24355

Catalin George Festila: Python Qt5 - MP3 player example.

$
0
0
This tutorial with PyQt5 will allow us to play an MP3 file using QtMultimedia.
I used a test.mp3 file in the same folder with my python script.
This is the source script:
import sys

from PyQt5 import QtCore, QtWidgets, QtMultimedia

if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
filename = 'test.mp3'
fullpath = QtCore.QDir.current().absoluteFilePath(filename)
media = QtCore.QUrl.fromLocalFile(fullpath)
content = QtMultimedia.QMediaContent(media)
player = QtMultimedia.QMediaPlayer()
player.setMedia(content)
player.play()
sys.exit(app.exec_())

Viewing all articles
Browse latest Browse all 24355

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>