private void InitializeBass() { if (!_initialized) { BassException.CheckBoolResult(NativeMethods.BASS_Init(-1, 44100, BassDeviceFlags.Default, _hWnd)); _initialized = true; } }
private void Dispose(bool disposing) { if (_disposed) { return; } BassException.CheckBoolResult(NativeMethods.BASS_Free()); _disposed = true; }
/// <summary> /// Registers the specified plugin. /// </summary> /// <param name="pluginName">The plugin name (do not provide any extension)</param> public void Register(string pluginName) { string fullPath = Path.Combine(BaseDirectory, pluginName + ".dll"); if (!File.Exists(fullPath)) { throw new FileNotFoundException("Could not find the plugin file.", fullPath); } SafePluginHandle pluginHandle = BassException.CheckHandleResult(NativeMethods.BASS_PluginLoad(fullPath, BassFlags.Unicode)); _registeredPlugins.Add(fullPath, pluginHandle); }
/// <summary> /// Loads the specified media file. /// </summary> /// <param name="fileName">Name of the file to load.</param> public void Load(string fileName) { CheckNotDisposed(); InitializeBass(); if (_currentStream != null) { // Unload previous stream _currentStream.Dispose(); _currentStream = null; } _currentStream = BassException.CheckHandleResult(NativeMethods.BASS_StreamCreateFile(false, fileName, 0, 0, BassFlags.Unicode)); }
/// <summary> /// Stops playing the currently loaded media /// </summary> public void Stop() { CheckNotDisposed(); CheckMediaLoaded(); BassException.CheckBoolResult(NativeMethods.BASS_ChannelStop(_currentStream)); }
/// <summary> /// Starts or resumes the currently loaded media. /// </summary> public void Play() { CheckNotDisposed(); CheckMediaLoaded(); BassException.CheckBoolResult(NativeMethods.BASS_ChannelPlay(_currentStream, false)); }