Search code examples
pythonpython-3.xffmpegpyglet

How to have avbin.dll in a local directory (not C:\Windows\System) (for pyglet 1.2.4)


Using pyglet 1.2.4, I am using avbin.dll to allow me to play audio and all sources say it needs to go into C:\Windows\System. This works, but I would like to put in in a local folder, so that when it is downloaded, the user does not need to explicitly put it there.

How can I make it so that I specify the directory of avbin.dll/have in the same folder as the code?

Here, avbin.dll is in the folder with the code, but I can't find how they did it. https://github.com/surajsinghbisht054/Python-Media-Player/tree/master/Python%20Media%20Player%20Version%200.0.1/Tools I tried going through it but I didn't find anything

I tried

pyglet.options["search_local_libs"]

but it was already set to true.

I also added it to the path variable, but this didn't change anything.

The intention was to be able to play audio files.

Additionally: Using pyglet 1.4, I tried using ffmpeg and ffmpeg-pyglet, which works great, except that pyglet.app.run() is required to stop the first part of the track playing on repeat, but its mainloop interferes with tkinter's and I can't seem to get either working in threads, which is why I reverted back to 1.2.4.


Solution

  • This can be solve by just creating an installer using NSIS [Nullsoft Scriptable Install System ] .It is easy to create an installer using NSIS just for reference i will show you !

     !include LogicLib.nsh
     !include x64.nsh
       # define installer name
       OutFile "mp3player_installer.exe"
    
    ;set the default install directoy to programfilesx86
    InstallDir $PROGRAMFILES32
    
     Section 
       ;checking system architechure 
       ;if 64bit set the installation path to SysWOW64 else to system32
       ${If} ${RunningX64} 
         SetOutPath "$WINDIR\SysWOW64\"
         File avbin.dll
       ${Else}
         SetOutPath "$WINDIR\System32\"
         File avbin.dll
       ${EndIf}
     SectionEnd
    
     Section
       ;set the output path to programfilesx86/Application dir
       SetOutPath "$INSTDIR\Mp3Player\"
       ;the file need to copy ref with File Attribute you can set multiple file refs here
        File Application.py
       ;just create an uninstaller 
        WriteUninstaller "$INSTDIR\Mp3Player\uninstall.exe"
     SectionEnd
    
     Section "Uninstall"
      # Always delete uninstaller first
      Delete "$INSTDIR\Mp3Player\uninstaller.exe"
    
      # now delete installed file
      Delete "$INSTDIR\Mp3Player\Application.py"
      Delete "$WINDIR\SysWOW64\avbin.dll"
    SectionEnd
    

    You can install NSIS Application and just create an installer.nsi file and copy this code and compile the script by just right click the installer.nsi file and select compile with NSIS Script the result will generate an installer for you !