Oct-11-2021, 04:27 PM
The solution was having to check the player state. so I did
from PySide2.QtCore import QUrl, QDir from PySide2.QtMultimedia import QMediaPlayer, QMediaContent import PySide2.QtWidgets as QtWidgets import sys app = QtWidgets.QApplication(sys.argv) # Does all the setup work required to use Qt player = QMediaPlayer() file = 'here.mp3' dir = QDir() media_content = QMediaContent(QUrl.fromLocalFile(f'{dir.currentPath()}/{file}')) # use full path here print(player.state()) player.setMedia(media_content) player.setVolume(70) if player.state() == player.StoppedState: # Check if player state is stopped player.play() sys.exit(app.exec_()) # Stops program from exiting
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags