Created
March 14, 2018 12:48
OrtizOL. Reproducir archivo WAV. C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Media; | |
using System.Windows.Forms; | |
namespace R810ReproducirWAV | |
{ | |
public partial class Principal : Form | |
{ | |
public Principal() | |
{ | |
InitializeComponent(); | |
} | |
private void btnReproducirWav_Click(object sender, EventArgs e) | |
{ | |
OpenFileDialog ofd = new OpenFileDialog(); | |
ofd.InitialDirectory = @"C:\Windows\Media"; | |
ofd.Filter = "Archivos WAV|*.wav|All File|*.*"; | |
if (DialogResult.OK == ofd.ShowDialog()) | |
{ | |
SoundPlayer reproductor = new SoundPlayer(ofd.FileName); | |
try | |
{ | |
reproductor.Play(); | |
} | |
catch (Exception) | |
{ | |
MessageBox.Show("Error al reproducir el archivo seleccionado."); | |
} | |
finally | |
{ | |
reproductor.Dispose(); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment