Pygame play background music and sound effects

1. Play background music

pygame.mixer.music.load()

Load MP3 format

 

 

Join pygame.mixer.init () can

 

Eleventh first argument: Views (n> 0), n = 0 1 during playback, the special value of -1, will loop. Implementation of the results with the results of the book inconsistent.

The second argument: the music starts playing music from the beginning of the 250s.

Enter pygame.mixer.music.stop in spyder IPython console in () to immediately stop the music

 

Load wav format

 

 

 

2. Play Audio

sound=pygame.mixer.Sound('')

Load MP3 format

 


Unable to open the music

 

 

Output sound.stop () to immediately stop the music
----------------
Disclaimer: This article is CSDN blogger "weixin_42416449 'original article, follow the CC 4.0 BY-SA copyright agreement , reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/weixin_42416449/article/details/80913087

Guess you like

Origin www.cnblogs.com/ygunoil/p/11551285.html