[英]How to have avbin.dll in a local directory (not C:\Windows\System) (for pyglet 1.2.4)
使用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/我嘗試過的工具,但沒有找到任何東西
我試過了
pyglet.options["search_local_libs"]
但是它已經設置為true。
我也將其添加到path變量中,但這沒有任何改變。
目的是能夠播放音頻文件。
另外:使用pyglet 1.4,我嘗試使用ffmpeg
和ffmpeg-pyglet
,它們工作得很好,除了需要pyglet.app.run()
來停止重復播放曲目的第一部分,但它的主循環會干擾tkinter和我似乎無法在線程中工作,這就是為什么我恢復為1.2.4的原因。
如果將avbin dll放在文件夾中(或使用安裝程序全局安裝),請輸入:
導入pyglet之后,如下所示:
import pyglet
pyglet.lib.load_library('avbin')
pyglet.have_avbin=True
它將加載並使用avbin
注意:在這種情況下,有時會出現dll not found錯誤,將avbin.dll復制到Windows-> SysWOW64目錄下(如果使用32位python)。
這可以通過僅使用NSIS [Nullsoft可腳本安裝系統]創建安裝程序來解決。使用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腳本進行編譯來編譯腳本,結果將為您生成一個安裝程序!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.