Playing soundssss

Can I play sounds?
I don’t mean long ones, just little ones, like explosions or gunshots.

Telemix - the changing face of telecoms.

1 Like

Interesting idea! You can add HTML5 <audio> tags anywhere you can add HTML.

Here’s an app that confronts the user with squeaky cat noises:

https://anvil.works/ide#clone:45VAT5CE5POJZQ4I=PFBAOEQ54UG5D3R5EVUMCGLW

Wow, that’s harsh :slight_smile:

So i guess I just need to load them in advance then trigger them with some call_js() shenanigans?

Yeah, that’s probably the best way. I’m not that familiar with <audio> tags but I think you can do something like

$('#mycatsound').play()

There’s also an autoplay property, and a controls property that renders a little player (although it doesn’t sound like you want them to have any visible aspects).

If you’re not familiar with calling JS from Anvil, have a look at the reference docs:

https://anvil.works/doc#calling-from-javascript-to-python

I shall have a play and see.

I regularly get writer’s block and have to divert my attention onto short projects with a clear conclusion just to get the juices flowing. Often they tend to be time wasting games :slight_smile:

My latest will be “Zombiezee” - a Pythons Vs Zombies game set on the Zambezi river…

@david.wylie have you got anywhere with Pythons vs. Zombies yet?

What with holidays and shows I’m afraid not.

I will make a concerted effort though …

1 Like

A post was split to a new topic: Sound advice (moved to new topic)