Python Forum
How to embed mp3 file with Pyinstaller
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to embed mp3 file with Pyinstaller
#1
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?
Reply


Messages In This Thread
How to embed mp3 file with Pyinstaller - by panoss - May-25-2017, 05:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Embed Matplotlib Graph to Tkinter? dimidgen 0 246 Mar-04-2024, 07:40 PM
Last Post: dimidgen
  Using pyinstaller with .ui GUI files - No such file or directory error diver999 3 3,406 Jun-27-2023, 01:17 PM
Last Post: diver999
  Interactive plots that can be embed in web page mouse9095 1 613 Jun-12-2023, 04:51 PM
Last Post: deanhystad
  embed python script in C programm gucio321 0 612 Feb-11-2023, 10:47 AM
Last Post: gucio321
  best way to embed passwords into scripts mikey6785 3 2,287 Aug-31-2022, 08:22 AM
Last Post: DeaD_EyE
  Pyinstaller distribution file seems too large hammer 4 2,748 Mar-31-2022, 02:33 PM
Last Post: snippsat
  problem with pyinstaller to create an executable file atlass218 0 2,578 May-15-2021, 11:01 AM
Last Post: atlass218
  Embed Python blender code flaviu2 0 1,504 Nov-16-2020, 06:33 PM
Last Post: flaviu2
  Pyinstaller create this error :“File ”multiprocessing\connection.py“, line 691 Formationgrowthhacking 2 3,644 Apr-30-2020, 10:26 AM
Last Post: buran
  the exe file by generated by pyinstaller ,can't get the PYTHONPATH roger2020 11 7,043 Jan-14-2020, 11:07 AM
Last Post: roger2020

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020