Guest User

Untitled

a guest
Jun 13th, 2026
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. You might need to install aplay to get this to work, not sure what you're using to play WAV files. Use:
  2.  
  3. sudo apt install alsa-utils
  4.  
  5. to install aplay.
  6.  
  7. The first script is what you'll run with the Mystic menu command GY, make sure the second script is in the same directory as the first script, usually /mystic/themes/default/scripts
  8.  
  9.  
  10. ############## login_wav.mpy ##############
  11.  
  12. import mystic_bbs as bbs
  13. import subprocess
  14. import os
  15.  
  16. # Path to this MPY script
  17. path = bbs.param_str(0)
  18. dir_path = os.path.dirname(path)
  19.  
  20. # Worker script and WAV file
  21. player_script = os.path.join(dir_path, "play_wav.py")
  22. wav_file = "/mystic/56k_mdm.wav"
  23.  
  24. # Suppress output so nothing leaks into the BBS session
  25. devnull = open(os.devnull, "w")
  26.  
  27. # Launch the worker and immediately return control to Mystic
  28. subprocess.Popen(
  29. ["python", player_script, wav_file],
  30. stdout=devnull,
  31. stderr=devnull,
  32. close_fds=True
  33. )
  34.  
  35.  
  36. ############## play_wav.py ##############
  37.  
  38. import sys
  39. import subprocess
  40. import os
  41.  
  42. def play_wav(wav_file):
  43. if not os.path.exists(wav_file):
  44. return
  45.  
  46. # aplay blocks, but that's fine because this script is detached from Mystic
  47. subprocess.call(["aplay", wav_file])
  48.  
  49. if len(sys.argv) > 1:
  50. play_wav(sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment