Python Forum
How to embed mp3 file with Pyinstaller - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to embed mp3 file with Pyinstaller (/thread-3465.html)



How to embed mp3 file with Pyinstaller - panoss - May-25-2017

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?


RE: How to embed mp3 file with Pyinstaller - panoss - May-25-2017

Finally the code works, I just had put it the wrong place!


RE: How to embed mp3 file with Pyinstaller - yleongtyl - Apr-01-2019

(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..