Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created March 14, 2018 12:48
OrtizOL. Reproducir archivo WAV. C#.
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