Exemplo n.º 1
0
 public virtual void Dispose()
 {
     if (!IsDisposed)
     {
         IsDisposed = Bass.StreamFree(Handle);
     }
 }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Frees all resources used by this instance.
        /// </summary>
        public void Dispose()
        {
            Bass.ChannelStop(_handle);
            Bass.StreamFree(_handle);

            _buffer = null;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Frees all resources used by the player.
 /// </summary>
 public virtual void Dispose()
 {
     try
     {
         if (Bass.StreamFree(Handle))
         {
             _handle = 0;
         }
     }
     finally { OnStateChanged(); }
 }
Exemplo n.º 5
0
 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 { }
 }
Exemplo n.º 6
0
        /// <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);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Frees up the resources used by this instant.
 /// </summary>
 public void Dispose() => BASS.StreamFree(_handle);
Exemplo n.º 8
0
 /// <summary>
 /// Dispose all resources used by this instance.
 /// </summary>
 public void Dispose() => Bass.StreamFree(_handle);