示例#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);
                     */

                    float duracionFadeIn = float.Parse(txtDuracion.Text);

                    float inicio = float.Parse(txtInicio.Text);

                    float duracionFadeOut = float.Parse(txtDuracionFadeOut.Text);

                    EfectoFadeIn = new EfectoFadeIn(reader, duracionFadeIn);

                    efectoFadeOut = new EfectoFadeOut(reader, inicio, 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();



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

                    sldTiempo.Maximum = reader.TotalTime.TotalSeconds;

                    timer.Start();

                    lblTiempoTotal.Text  = reader.TotalTime.ToString().Substring(0, 8);
                    lblTiempoActual.Text = reader.CurrentTime.ToString().Substring(0, 8);
                }
            }
        }
示例#2
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);*/

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

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

                    efectoFadeOut =
                        new EfectoFadeOut(efectoFadeIn,
                                          float.Parse(txtFadeOutInicio.Text),
                                          float.Parse(txtFadeOutDuracion.Text));

                    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;

                    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();
                }
            }
        }