Csharp/C Sharp/Development Class/SoundPlayer — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 15:31, 26 мая 2010
new SoundPlayer(openDialog.FileName) Play
using System;
using System.Windows.Forms;
using System.Media;
public class MainClass {
public static void Main() {
// Allow the user to choose a file.
OpenFileDialog openDialog = new OpenFileDialog();
openDialog.Filter = "WAV Files|*.wav|All Files|*.*";
if (DialogResult.OK == openDialog.ShowDialog()) {
SoundPlayer player = new SoundPlayer(openDialog.FileName);
try {
player.Play();
} catch (Exception) {
MessageBox.Show("An error occurred while playing media.");
} finally {
player.Dispose();
}
}
}
}