使用 pyglet 1.2.4,我正在使用 avbin.dll 来播放音频,所有消息来源都说它需要进入 C:\Windows\System。这可行,但我想放在本地文件夹中,这样当下载它时,用户不需要明确地把它放在那里。
我怎样才能使它在与代码相同的文件夹中指定 avbin.dll/have 的目录?
在这里,avbin.dll 位于包含代码的文件夹中,但我找不到他们是如何做到的。
https://github.com/surajsinghbisht054/Python-Media-Player/tree/master/Python%20Media%20Player%20Version%200.0.1/Tools
我试图通过它,但我没有找到任何东西
我试过了
pyglet.options["search_local_libs"]
但它已经设置为true。
我还将它添加到路径变量中,但这并没有改变任何东西。
目的是能够播放音频文件。
此外:
使用 pyglet 1.4,我尝试使用
ffmpeg
和 ffmpeg-pyglet
,效果很好,除了 pyglet.app.run()
需要停止重复播放轨道的第一部分,但它的主循环会干扰 tkinter 的,我似乎无法在线程中工作,这就是我恢复到 1.2.4 的原因。
最佳答案
这可以通过使用 NSIS [Nullsoft Scriptable Install System] 创建安装程序来解决。使用 NSIS 创建安装程序很容易,仅供引用,我将向您展示!
!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
您可以安装 NSIS 应用程序并创建一个 installer.nsi 文件并复制此代码并编译脚本,只需右键单击 installer.nsi 文件并选择使用 NSIS 脚本编译,结果将为您生成一个安装程序!
关于python - 如何在本地目录中有 avbin.dll(不是 C :\Windows\System) (for pyglet 1. 2.4),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56118594/