Exemplo n.º 1
0
    public void stop()
    {
        if (!running)
        {
            return;
        }

        running = false;

        MainActivity.Instance.VolumeControlStream = Stream.NotificationDefault;

        if (audioPlayer != null)
        {
            try
            {
                audioPlayer.Stop();
                audioPlayer.Release();
            }
            catch (Exception)
            {
            }

            audioPlayer.Dispose();
            audioPlayer = null;
        }

        if (audioDecoder != null)
        {
            audioDecoder.stop();
            audioDecoder.Dispose();
            audioDecoder = null;
        }

        bufferSize = 0;
    }
Exemplo n.º 2
0
    public void stop()
    {
        if (!running)
        {
            return;
        }

        running = false;

        if (audioPlayer != null)
        {
            try
            {
                audioPlayer.Stop();
            }
            catch (Exception)
            {
            }

            audioPlayer.Dispose();
            audioPlayer = null;
        }

        if (audioDecoder != null)
        {
            audioDecoder.stop();
            audioDecoder.Dispose();
            audioDecoder = null;
        }

        if (provider != null)
        {
            provider.ClearBuffer();
        }
    }
Exemplo n.º 3
0
        private void ProcessFileCallback(string fingerprint, long time)
        {
            Action action = () =>
            {
                fp = fingerprint;
                // Release audio file handle.
                decoder.Dispose();
            };

            Dispatcher.BeginInvoke(action);
        }
Exemplo n.º 4
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "MP3 files (*.mp3)|*.mp3|WAV files (*.wav)|*.wav";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (decoder != null)
                {
                    decoder.Dispose();
                }

                try
                {
                    decoder = new NAudioDecoder(dlg.FileName);
                    //decoder = new BassDecoder();

                    lbFile.Text = dlg.FileName;

                    ResetAll();

                    int bits     = decoder.Format.BitDepth;
                    int channels = decoder.Format.Channels;

                    lbAudio.Text = String.Format("{0}Hz, {1}bit{2}, {3}",
                                                 decoder.Format.SampleRate, bits, bits != 16 ? " (not supported)" : "",
                                                 channels == 2 ? "stereo" : (channels == 1 ? "mono" : "multi-channel"));

                    lbDuration.Text = decoder.Format.Duration.ToString();

                    btnFingerPrint.Enabled = true;
                }
                catch
                {
                    lbAudio.Text    = "Failed to load audio";
                    lbDuration.Text = String.Empty;
                }
            }
        }
Exemplo n.º 5
0
 public void Dispose()
 {
     if (!AudioSystem.Active)
     {
         return;
     }
     if (decoder != null)
     {
         decoder.Dispose();
     }
     DisposeOpenALResources();
     Marshal.FreeHGlobal(decodedData);
 }
Exemplo n.º 6
0
    public void stop()
    {
        if (!running)
        {
            return;
        }

        running = false;

        AVAudioSession.SharedInstance().SetActive(false);

        if (audioPlayer != null)
        {
            try
            {
                audioPlayer.Stop();
                audioPlayer.Reset();
            }
            catch (Exception)
            {
            }

            audioPlayer.Dispose();
            audioPlayer = null;
        }

        if (audioDecoder != null)
        {
            audioDecoder.stop();
            audioDecoder.Dispose();
            audioDecoder = null;
        }

        if (audioEngine != null)
        {
            try
            {
                audioEngine.Stop();
                audioEngine.Reset();
            }
            catch (Exception)
            {
            }

            audioEngine.Dispose();
            audioEngine = null;
        }
    }
Exemplo n.º 7
0
 public void Dispose()
 {
     Decoder?.Dispose();
 }
Exemplo n.º 8
0
 public void Dispose() => Decoder?.Dispose();