2019-05-08 13:02:16

So I recently have been learning python, I have got the most basic things,
functions, if, and way's to show data.
And how to save data to a file.
So, I started to make a little text adventure game. it all went well, I even got it to get a message of the day from my website.
However I wanted to add sound.
So I installed pygame and had a little fiddle. I saw that I could load sound tracks and stop them.
So i added a track, but my question is, how would i stop the play back of a sound. am I missing something here?
i did.

    mixer.music.load("Hiding Your Reality.mp3")

Have a lovely day.

2019-05-08 13:24:26

you have axcedently created two topics, delete one of em.

Thumbs up

2019-05-08 14:31:28

lol sorry.
for some reason i clicked the button 1 time, it made 2.
again sorry about that.

Have a lovely day.

2019-05-08 16:17:54

Hmm, I think pygame.mixer.music.load returns a sound object.
Assign it to the variable sound, for example, then call sound.stop().
That should stop it.

My tactical battle scripts: https://www.dropbox.com/s/dzsmqv2pgqvu1 … h.zip?dl=1
Currently, one of my favorite games is Trimps.
So I'm the Trimper Trooper!

Thumbs up

2019-05-08 18:57:26

Exactly. You have to load the sound into a sound variable. Not nesesarily "sound", could be anything you like. But it's how it works. Then you do the required actions on that variable. Of course you can load a sound and put a .play() after loading the sound and it plays the sound but it's just that. You won't be able to change the volume at all, or do other stuff. You either can load then instantly play, or you can load and instantly change volume. No third level action on the sound can be done without declaring a variable

Add me on skype: kianoosh.shakeri2
Or follow me on twitter @kianoosh shakeri