Closed probonopd closed 3 years ago
Let's create a system-wide theme and use it. For example, the "Success" sound from https://freesound.org/people/Leszek_Szary/sounds/171670/, https://freesound.org/data/previews/171/171670_2437358-lq.mp3.
Since I could not get QMultimedia to play sound from Python, why not just use
os.system("mpg123 /tmp/171670_2437358-lq.mp3")
and call it a day... This plays the file super instantly without skipping the first few hundred ms on FreeBSD 13. Cool!
Not working:
import os import sys from PyQt5 import QtCore, QtMultimedia CURRENT_DIR = os.path.dirname(os.path.realpath(__file__)) def main(): print("Playing sound") # https://freesound.org/people/Leszek_Szary/sounds/171670/, licensed under CC0 if os.path.exists(os.path.dirname(__file__) + '/success.ogg'): soundfile = os.path.dirname(__file__) + '/success.ogg' elif os.path.exists("/usr/local/share/sounds/freedesktop/stereo/complete.oga"): soundfile = "/usr/local/share/sounds/freedesktop/stereo/complete.oga" else: print("No sound available, pkg install freedesktop-sound-theme") app = QtCore.QCoreApplication(sys.argv) QtMultimedia.QSound.play(soundfile) # end in 5 seconds: QtCore.QTimer.singleShot(5 * 1000, app.quit) sys.exit(app.exec_()) if __name__ == "__main__": main()
Why?
https://github.com/helloSystem/Utilities/commit/4abe5e86cb2072d34aa0ddc2f5307c4929d7fbcf
Let's create a system-wide theme and use it. For example, the "Success" sound from https://freesound.org/people/Leszek_Szary/sounds/171670/, https://freesound.org/data/previews/171/171670_2437358-lq.mp3.
Since I could not get QMultimedia to play sound from Python, why not just use
and call it a day... This plays the file super instantly without skipping the first few hundred ms on FreeBSD 13. Cool!
Not working:
Why?