Example #1
0
        private void btnReproducir_Click(object sender, RoutedEventArgs e)
        {
            if (output != null &&
                output.PlaybackState == PlaybackState.Paused)
            {
                // retomo reproduccion
                output.Play();
                btnReproducir.IsEnabled = false;
                btnPausa.IsEnabled      = true;
                btnDetener.IsEnabled    = true;
            }
            else
            {
                if (txtRutaArchivo.Text != null &&
                    txtRutaArchivo.Text != string.Empty)
                {
                    reader =
                        new AudioFileReader(txtRutaArchivo.Text);

                    /*volume =
                     *  new VolumeSampleProvider(reader);
                     * volume.Volume =
                     *  (float)(sldVolumen.Value);*/
                    efectoFadeIn = new EfectoFadeIn(reader, 5.0f);

                    efectoVolumen         = new EfectoVolumen(reader);
                    efectoVolumen.Volumen =
                        (float)(sldVolumen.Value);

                    output = new WaveOut();
                    output.DeviceNumber =
                        cbDispositivoSalida.SelectedIndex;
                    output.PlaybackStopped += Output_PlaybackStopped;
                    output.Init(efectoVolumen);
                    output.Play();

                    //Cambiar el volumen del output

                    /*output.Volume =
                     *  (float)(sldVolumen.Value);*/

                    btnReproducir.IsEnabled = false;
                    btnPausa.IsEnabled      = true;
                    btnDetener.IsEnabled    = true;

                    lblTiempoTotal.Text =
                        reader.TotalTime.ToString().
                        Substring(0, 8);
                    lblTiempoActual.Text =
                        reader.CurrentTime.ToString().
                        Substring(0, 8);

                    sldTiempo.Maximum = reader.TotalTime.TotalSeconds;
                    sldTiempo.Value   = reader.CurrentTime.TotalSeconds;

                    timer.Start();
                }
            }
        }
Example #2
0
        private void BtnReproducir_Click(object sender, RoutedEventArgs e)
        {
            if (output != null && output.PlaybackState == PlaybackState.Paused)
            {
                //Retorno reproduccion
                output.Play();
                btnReproducir.IsEnabled = false;
                btnPausa.IsEnabled      = true;
                btnDetener.IsEnabled    = true;
            }
            else
            {
                if (txtRutaArchivo.Text != null && txtRutaArchivo.Text != string.Empty)
                {
                    reader = new AudioFileReader(txtRutaArchivo.Text);

                    //volume = new VolumeSampleProvider(reader);
                    //volume.Volume = (float)(sldVolumen.Value);

                    efectoDelay = new EfectoDelay(reader, (int)(sldOffsetDelay.Value), (float)(sldGananciaDelay.Value));

                    float duracionFadeIn = float.Parse(txtDuracion.Text);
                    efectoFadeIn = new EfectoFadeIn(efectoDelay, duracionFadeIn);

                    float duracionFadeOut = float.Parse(txtDuracionFadeOut.Text);
                    float inicioFadeOut   = float.Parse(txtInicioFadeOut.Text);
                    efectoFadeOut = new EfectoFadeOut(reader, inicioFadeOut, duracionFadeOut);

                    efectoVolumen         = new EfectoVolumen(efectoFadeOut);
                    efectoVolumen.Volumen = (float)(sldVolumen.Value);

                    output = new WaveOut();
                    output.DeviceNumber     = cbDispositivoSalida.SelectedIndex;
                    output.PlaybackStopped += Output_PlaybackStopped;
                    output.Init(efectoVolumen);
                    output.Play();

                    //Cambiar el volumen del output
                    //output.Volume = (float)(sldVolumen.Value);

                    btnReproducir.IsEnabled = false;
                    btnPausa.IsEnabled      = true;
                    btnDetener.IsEnabled    = true;

                    lblTiempoFinal.Text  = reader.TotalTime.ToString().Substring(0, 8);
                    lblTiempoActual.Text = reader.CurrentTime.ToString().Substring(0, 8);

                    sldTiempo.Maximum = reader.TotalTime.TotalSeconds;
                    sldTiempo.Value   = reader.CurrentTime.TotalSeconds;

                    timer.Start();
                }
            }
        }