title: How to play mp3 from bytes?
body: <p>Is there a way to play mp3 from bytes directly using python? If not, can I convert the binary to a different audio format and make the binary playable?</p>
  
  <p>Edit: The following code works for <code>wav</code> files but not <code>mp3</code></p>
  
  <pre><code>from pygame import mixer, time
  
  mixer.pre_init(44100, -16, 2, 2048)
  mixer.init()
  
  data = open('filename.mp3', 'rb').read()
  sound = mixer.Sound(buffer=data)
  
  audio = sound.play()
  while audio.get_busy():
      time.Clock().tick(10)
  </code></pre>
  
  <p>Edit:
  The problem has been solved, see my answer below if you're facing a similar issue</p>