Python:在后台播放音乐?
我目前正在用Python做游戏.我不使用PyGame,仅使用控制台(非GUI) 当您开始游戏时,您将获得游戏的徽标,以及有关您刚刚开始的旅程"的许多信息.文本很多,所以在滚动文本时,我想在后台播放一首歌.
I am currently making a game in Python. I am not using PyGame, just the console (non-GUI) When you start the game, you will get the logo to the game, and a lot of information about the "journey" you just started. There is a lot of text, so while the text is scrolling, I want to have a song played in the background.
我用以下代码开始音乐:
I start the music with the following code:
def new_game():
import winsound
winsound.PlaySound("intro.wav", winsound.SND_ALIAS)
LVL1_INTRO()
唯一的问题是:在音乐停止播放之前,它不会继续LVL1_INTRO().这是一个问题,因为音乐大约需要1-2分钟.
The only problem is: it won't continue to LVL1_INTRO() until the music have stopped playing. It's a problem, as the music is approximately 1-2 minutes long.
有什么办法可以解决这个问题?音乐开始播放后,它将继续显示LVL1_INTRO()
Is there any way to fix this? After the music have started, it will continue with LVL1_INTRO()
如果可能的话,如果也有用于停止音乐的代码,我会很高兴,因此我不需要开始剪切音乐,并且使其长度与简介完全相同.
If it is possible, I would be happy if there is a code for stopping the music as well, so I don't need to start cutting the music, and make it exactly the same lenght as the intro.
非常感谢!