-
Hi Textual friends and community! Currently, if I use the playsound library to play audio on mount, it plays the audio before displaying any widgets on the screen. Is there a better event to wait for all widgets to be displayed before playing a sound? Here's a brief example of my troubles: pyproject.toml deps[tool.poetry.dependencies]
python = ">=3.11,<4.0"
textual = "^0.56"
playsound = {git = "https://github.com/taconi/playsound"}
pyfiglet = "^1.0" from playsound import playsound
from pyfiglet import Figlet
from textual.app import App, ComposeResult
from textual.containers import Grid
from textual.widgets import Label
class BaseApp(App):
def compose(self) -> ComposeResult:
with Grid(id="base-screen-container"):
yield Label(Figlet(font="standard").renderText("reminder"))
def on_mount(self) -> None:
playsound("./snackaroo_jenny.mp3")
if __name__ == "__main__":
app = BaseApp()
app.run() Here's the audio file I was using to test: snackaroo_jenny.mp3.gz Thanks for any help you can give 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Presumably this library you mention will be playing the sound in a way that is blocking for the application. You'll need to come up with some way of playing it in the background; maybe threaded workers will help you here. |
Beta Was this translation helpful? Give feedback.
Presumably this library you mention will be playing the sound in a way that is blocking for the application. You'll need to come up with some way of playing it in the background; maybe threaded workers will help you here.