Background Music for Python Games



Hello! I just started making this text-based game via Python (it doesn't use Pygame), and I'm thinking I may want background music for it in the future. How would I go about doing this?


you could try adding something to the beginning of your python file that opens an external html file that only plays a song on loop or something as soon as you execute the python file.


how would you do that


check this out


I'll try that, then report back.


Alright so I did some more searching and found an actual solution...

Add this to your code:

import webbrowser

new = 2

url = "file://path"
# eg: "file://C:/Users/Student/Desktop/pytest.html", new=new)

You can refer to: this link


So to summarize, you need to write your own html file that plays a song of your choice and then after you create the file, link to it with the above method, and you're good to go :)


Thanks to both of you!

P.S. kogeyamauchiha, congratulations for being a Naruto fan. :slight_smile: