public static void InitResources(IntPtr win, string bassEmail, string bassCode) { //This function shall only be executed once! At least NUnit has a problem if executed multiple times. if (isInitialized) { return; } string targetPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); //if (Utils.Is64Bit) // targetPath = Path.Combine(targetPath, "libs/x64"); //else // targetPath = Path.Combine(targetPath, "libs/x86"); if (!string.IsNullOrEmpty(bassEmail) && !string.IsNullOrEmpty(bassCode)) { BassNet.Registration(bassEmail, bassCode); } if (Utility.IsWindowsOS()) { #if __MonoCS__ //mono specific code for linux. LoadMe is not available and not needed. #else //for Windows Bass.LoadMe(); BassMix.LoadMe(); BassFlac.LoadMe(); BassAac.LoadMe(); #endif } bool isBassInit = Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, win); if (!isBassInit) { throw new ApplicationException("Some errors occurred while initializing audio dll"); } isInitialized = true; }
public override bool Load(byte[] audio, bool looping, string identifier = null) { if (!base.Load(audio, looping, identifier)) { return(false); } FreeMusic(); audioHandle = GCHandle.Alloc(audio, GCHandleType.Pinned); if (identifier.Contains("mp3")) { audioStream = Bass.BASS_StreamCreateFile(audioHandle.AddrOfPinnedObject(), 0, audio.Length, BASSFlag.BASS_STREAM_PRESCAN | (looping ? BASSFlag.BASS_MUSIC_LOOP : 0)); } else { audioStream = BassAac.BASS_MP4_StreamCreateFile(audioHandle.AddrOfPinnedObject(), 0, audio.Length, BASSFlag.BASS_STREAM_PRESCAN | (looping ? BASSFlag.BASS_MUSIC_LOOP : 0)); } updateVolume(); return(true); }