Advertisement
Fhernd

Principal.cs

Mar 14th, 2018
1,135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2. using System.Media;
  3. using System.Windows.Forms;
  4.  
  5. namespace R810ReproducirWAV
  6. {
  7.     public partial class Principal : Form
  8.     {
  9.         public Principal()
  10.         {
  11.             InitializeComponent();
  12.         }
  13.  
  14.         private void btnReproducirWav_Click(object sender, EventArgs e)
  15.         {
  16.             OpenFileDialog ofd = new OpenFileDialog();
  17.             ofd.InitialDirectory = @"C:\Windows\Media";
  18.             ofd.Filter = "Archivos WAV|*.wav|All File|*.*";
  19.  
  20.             if (DialogResult.OK == ofd.ShowDialog())
  21.             {
  22.                 SoundPlayer reproductor = new SoundPlayer(ofd.FileName);
  23.  
  24.                 try
  25.                 {
  26.                     reproductor.Play();
  27.                 }
  28.                 catch (Exception)
  29.                 {
  30.                     MessageBox.Show("Error al reproducir el archivo seleccionado.");
  31.                 }
  32.                 finally
  33.                 {
  34.                     reproductor.Dispose();
  35.                 }
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement