How to play music using pygame (Python)
<p>I am trying to play an .mp3 file using pygame. Here is my code:</p>

<pre><code>import pygame

pygame.init()
pygame.mixer.init()

pygame.mixer.music.load('MSM.mp3')
pygame.mixer.music.play(0)

pygame.event.wait()
</code></pre>

<p>This however does not actually play the file. The audio file is located within the same folder as the .py file.</p>

<p>The pyGame docs suggest using the pygame.mixer.pre_init() method before the top-level pygame.init() on some platforms.</p>

<blockquote>
  <p>"Some platforms require the pygame.mixer module for loading and
  playing sounds module to be initialized after the display modules have
  initialized. The top level pygame.init() takes care of this
  automatically, but cannot pass any arguments to the mixer init. To
  solve this, mixer has a function pygame.mixer.pre_init() to set the
  proper defaults before the toplevel init is used."
  <a href="https://www.pygame.org/docs/ref/mixer.html#pygame.mixer.init" rel="nofollow">https://www.pygame.org/docs/ref/mixer.html#pygame.mixer.init</a></p>
</blockquote>

python pygame music