怎么样在c#程序中放音乐
来源:互联网 发布:2017药品中标数据目录 编辑:程序博客网 时间:2024/05/17 06:52
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;
namespace 宿舍管理系统
{
public partial class main : Form
{
private SoundPlayer myplayer = new SoundPlayer();
Microsoft.VisualBasic.Devices.Computer my = new Microsoft.VisualBasic.Devices.Computer();
private string strFileName;
private void paly()
{
try
{
if (strFileName!=null)
{
my.Audio.Play(strFileName, Microsoft.VisualBasic.AudioPlayMode.BackgroundLoop);
}
else
{
my.Audio.Play("123.wav", Microsoft.VisualBasic.AudioPlayMode.BackgroundLoop);
}
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString(), "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
}
public main()
{
InitializeComponent();
}
private void fdfToolStripMenuItem5_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void 亭ToolStripMenuItem_Click(object sender, EventArgs e)
{
my.Audio.Stop();
}
private void 开始背景音乐ToolStripMenuItem_Click(object sender, EventArgs e)
{
paly();
}
private void main_Load(object sender, EventArgs e)
{
paly();
}
private void 放音乐ToolStripMenuItem_Click(object sender, EventArgs e)
{
openmusic();
myplayer.PlayLooping();
}
private void openmusic()
{
try
{
OpenFileDialog mydlg = new OpenFileDialog();
mydlg.CheckFileExists = true;
mydlg.Filter = "WAV faies(*.wav)|*.wav";
if (mydlg.ShowDialog() == DialogResult.OK)
{
myplayer.SoundLocation = mydlg.FileName.ToString();
}
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString(), "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
}
private void 亭止放音乐ToolStripMenuItem_Click(object sender, EventArgs e)
{
myplayer.Stop();
}
private void toolStripButton3_Click(object sender, EventArgs e)
{
openmusic();
myplayer.PlayLooping();
}
private void 更换背景音乐ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog mydlg = new OpenFileDialog();
mydlg.CheckFileExists = true;
mydlg.Filter = "WAV faies(*.wav)|*.wav";
if (mydlg.ShowDialog() == DialogResult.OK)
{
strFileName= mydlg.FileName.ToString();
}
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString(), "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
}
}
}
- 怎么样在c#程序中放音乐
- 怎么样在c#程序中放音乐
- 怎么样把层放在flash上面
- 在控制台程序中播放音乐
- 在C#中怎么样声明全局变量和宏定义
- 在大程序中怎么样显示LED点阵
- C#中生成DLL放在指定目录
- C#中 dll文件放在子目录中的方法
- c#程序不必把dll放在exe目录下--app.config文件中添加dll程序集的查找目录
- 程序中播放音乐
- 学了好久 怎么样写c#在程序中的代码 还不会写代码
- 如何在你做的JAVA程序中加音乐
- 在iPhone程序中使用后台音乐播放和VoIP
- 在程序中实现插入音乐的代码及详解
- 要在J2ME中播放音乐的文件,必须放在项目文件夹下,而不是包下
- C#播放音乐,调用程序
- 怎么样倾听音乐?
- C#将个性化字体放在资源文件内供程序调用
- DC综合过程
- 好宝贝走四方 选快递最重要
- Dom4j的使用
- 惠普的BI谋略
- 本人的QQ群:有来的可以加。
- 怎么样在c#程序中放音乐
- 一个实用垃圾清除的批处理
- 消息队列
- 网站用户单点登陆解决方案
- 自己从程序中创建位图,然后将其显示出来
- SQL注入批量更新语句
- 在普通web项目的servlet和filter中获取spring上下文
- Servlet中的Listener
- Servlet和Filter的url匹配以及url-pattern详解