public virtual void Dispose() { if (!IsDisposed) { IsDisposed = Bass.StreamFree(Handle); } }
/// <summary> /// Reads tags from a File. /// </summary> public static TagReader Read(string FileName) { Bass.Init(); var h = Bass.CreateStream(FileName, Flags: BassFlags.Prescan); TagReader result = null; if (h != 0) { result = Read(h); Bass.StreamFree(h); } else { h = Bass.MusicLoad(FileName, Flags: BassFlags.Prescan); if (h != 0) { result = Read(h); Bass.MusicFree(h); } } if (!string.IsNullOrWhiteSpace(result?.Title)) { result.Title = System.IO.Path.GetFileNameWithoutExtension(FileName); } return(result); }
/// <summary> /// Frees all resources used by this instance. /// </summary> public void Dispose() { Bass.ChannelStop(_handle); Bass.StreamFree(_handle); _buffer = null; }
/// <summary> /// Frees all resources used by the player. /// </summary> public virtual void Dispose() { try { if (Bass.StreamFree(Handle)) { _handle = 0; } } finally { OnStateChanged(); } }
public void FreeStream() { try { if (_handle != 0) { _Length = 0; // Position = -1; Bass.StreamFree(_handle); Bass.ChannelStop(_handle); // (StreamFree) Stop Playback. Bass.MusicFree(_handle); _handle = 0; } } catch { } }
/// <summary> /// Loads a file into the player. /// </summary> /// <param name="FileName">Path to the file to Load.</param> /// <returns><see langword="true"/> on succes, <see langword="false"/> on failure.</returns> public async Task <bool> LoadAsync(string FileName) { try { if (Handle != 0) { Bass.StreamFree(Handle); } } catch { } if (_dev != -1) { Bass.CurrentDevice = _dev; } var currentDev = Bass.CurrentDevice; if (currentDev == -1 || !Bass.GetDeviceInfo(Bass.CurrentDevice).IsInitialized) { Bass.Init(currentDev); } var h = await Task.Run(() => OnLoad(FileName)); if (h == 0) { return(false); } Handle = h; var tags = TagReader.Read(Handle); Title = !string.IsNullOrWhiteSpace(tags.Title) ? tags.Title : Path.GetFileNameWithoutExtension(FileName); Artist = tags.Artist; Album = tags.Album; InitProperties(); MediaLoaded?.Invoke(h); OnPropertyChanged(""); return(true); }
/// <summary> /// Frees up the resources used by this instant. /// </summary> public void Dispose() => BASS.StreamFree(_handle);
/// <summary> /// Dispose all resources used by this instance. /// </summary> public void Dispose() => Bass.StreamFree(_handle);