using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Media;
using System.Resources;
using System.IO;
namespace SoundPlayerApp
{
public partial class Form1 : Form
{
private SoundPlayer simpleSound;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog OpenFileDialog1 = new OpenFileDialog();
OpenFileDialog1.Filter = "Wav 文件(*.wav)|*.wav";
if (OpenFileDialog1.ShowDialog() == DialogResult.OK)
{
simpleSound = new SoundPlayer(OpenFileDialog1.FileName);
simpleSound.Play();
}
}
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog OpenFileDialog1 = new OpenFileDialog();
OpenFileDialog1.Filter = "Wav 文件(*.wav)|*.wav";
if (OpenFileDialog1.ShowDialog() == DialogResult.OK)
{
simpleSound = new SoundPlayer(OpenFileDialog1.FileName);
simpleSound.PlayLooping();
}
}
private voi

这是一个C#应用程序,演示了多种播放Wav音频的方法,包括使用SoundPlayer类,从资源文件中播放,从文件对话框选择文件播放,以及使用WinAPI和系统声音播放。此外,还涵盖了循环播放、停止播放以及从资源中创建和播放Wav文件的功能。
最低0.47元/天 解锁文章
175

被折叠的 条评论
为什么被折叠?



