Python Forum

Full Version: How to embed mp3 file with Pyinstaller
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I 'm tryin to use an mp3 in my app.
This is how:
def _response_to_alert(self):
  if getattr(sys, 'frozen', False):
    # we are running in a bundle
    bundle_dir = sys._MEIPASS
else:
    # we are running in a normal Python environment
    bundle_dir = os.path.dirname(os.path.abspath(file))
file = os.path.join(bundle_dir, 'foghorn.mp3')

pygame.mixer.music.load(file)
pygame.mixer.music.play(-1)
In my spec file, I have: datas= [('betws.ui','.'), ('foghorn.mp3', '.')],

But it' s not working.
What am I doing wrong?
Finally the code works, I just had put it the wrong place!
(May-25-2017, 08:37 PM)panoss Wrote: [ -> ]Finally the code works, I just had put it the wrong place!

Please teach me how to do this,
I been finding so many source online but still have no idea how to do this..