- 2
- 0
- 约2.08千字
- 约 5页
- 2021-02-05 发布于山东
- 举报
WPF 使用声音资源
1.在项目上右键, 增加 Resources 文件夹;在 Resources
文件夹上右键,增加 Audio 文件夹;往 Audio 文件夹中增加
声音资源文件: didi.wav 。
右键 didi.wav ,选择属性,设置属性复制到输出目录为始终复制;生成操作为嵌入的资源。
增加播放声音文件的代码。
1 private void Play()
2
{
3
SoundPlayer soundPlayer =
new
SoundPlayer(System.Environment.CurrentDirectory +
@\Resources\Audio\didi.wav);
4 //或者
5 //SoundPlayer soundPlayer = new
SoundPlayer(@Resources\Audio\didi.wav);
6
7 soundPlayer.PlayLooping();
8 } 路径也可以这样写
public static Dictionarylt;string,stringgt;
soundsDict; static MessagePane(){
soundsDict = new Dictionarylt;string,
stringgt;();
soundsDict[MessageType.VALIDCASE_DISPATCH] =
原创力文档

文档评论(0)