我采用的下面的来做播放音乐的库
Un4seen Developments - Welcome
其介绍是
ASS is an audio library for use in software on several platforms. Its purpose is to provide developers with powerful and efficient sample, stream (MP3, MP2, MP1, OGG, WAV, AIFF, custom generated, and more via OS codecs and add-ons), MOD music (XM, IT, S3M, MOD, MTM, UMX), MO3 music (MP3/OGG compressed MODs), and recording functions. All in a compact DLL that won't bloat your distribution.
C/C++, Delphi, and Visual Basic APIs are provided, with several examples to get you started. .NET and other APIs are also available.
且有 Win32 macOS Linux Android iOS 等平台原生编译DLL
对于DLL(bass.dll),有提供了很多不同语言 API 调用DLL 的Demo,基本可以直接拿来用。
但是...(但是会存在这样的文件部署结构)
主程序.exe ,
bass.dll(un4seen 库) ,
bassAPI.dll,
Music1.xm,
Music2.mp3
至少4~5个文件尾巴,极大不利益传播与分发。
所以就想全部压入资源,内存中加载DLL,内存中调用DLL,再调内存中的音乐文件播放。这样硬盘没有任何多余的物理文件存在。
那就开动
1、准备原生DLL (主要可考虑Windows 平台,其他平台类似。)
官网下载 Un4seen Developments - BASS Win32包,里面找到32位,64位DLL
改名为 bass_32.dll 与bass_64.dll ,并且压入程序资源内,如下图