#๐Ÿ”’ Tried using playsound3 for nonblocking sound playing now the script broke.

14 messages ยท Page 1 of 1 (latest)

serene mulch
#

Hello!

Idk how I should show my code so I will just explain it for now:

I'm making a program where you can search for and play sounds. I use playsound and threads until now. But I wanted to add an option to stop sounds. For that I switch to playsound3 because than I can use .is_alive() and .stop() to accomplish my goal (first pic).
Whole structure:

  1. a thread is started with a variable containing filepaths
    2.the filepaths are separated into their own "sub"threads and added to a list -> in a for loop they are .start()-ed and .join()-ed so the main thread waits
  2. inside the "sub"threads playsound is called
  3. once every subthread returned the main thread returns
  4. in the main loop there is the second pic's code that joins finished main threads

But after this change the code now waits for the main thread to join.

Hope this is understandable.

frozen egretBOT
#

@serene mulch

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

native badger
#

!code

frozen egretBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

serene mulch
#

What do I do with the pastebin?

native badger
#

Why do you need threads ?

serene mulch
#

It's a "leftover" from when I used normal playsound()

#

And I didn't change it since it should have worked the same

serene mulch
native badger
#

Honeslty I don't know what your main threads block

#

But if you don't need threads anymore it will be way easier to remove everything

frozen egretBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.