Skip to content
Sign upLog in
← Back to Community
Music in python??
Profile icon
FloCal35

Is there/how do you get music in Python. I need it for my upcoming major post that is Star Wars themed (of course) and could use the main theme (or duel of the fates) playing in the background.

Answered by RYANTADIPARTHI [earned 5 cycles]
View Answer
Voters
Profile icon
JonahCrawford
Profile icon
FloCal35
Comments
hotnewtop
Profile icon
RYANTADIPARTHI

Solution

Here you go:

from replit import audio def main(): source = audio.play_file('audio.wav') main()

and you need to upload your audio file into your repl, and put it in play_file
here's a link for more info:

https://docs.repl.it/repls/audio

Profile icon
Coder100

Try this: https://docs.repl.it/repls/audio

You will have to use their special library because they run a virtual machine, and thus cannot play sound.

from replit import audio audio.play_file('<INSERT AUDIO FILE HERE>.wav')
Profile icon
littlepenguin

Here:

from replit import audio while how_many_loops: audio.play_file("star_wars_duel_of_the_fates_battle.mp3") # make sure that you have this file in your project. print("Music ended! Obi-Wan Kenobi won.")