怎么设置C#窗体背景音乐为mp3.rm.wma格式。

LJH20002004200820131 2009-03-03 09:10:22
我找了很多相关资料 背景音乐都是wav格式的。希望哪位大侠能指点下如何将背景音乐设置为mp3或者是rm.或者wma格式。
...全文
957 32 打赏 收藏 转发到动态 举报
写回复
用AI写文章
32 条回复
切换为时间正序
请发表友善的回复…
发表回复
LoveTXJ1988 2010-11-28
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 zhaozhijun0207 的回复:]
C# code

using System.Runtime.InteropServices;

public static uint SND_ASYNC = 0x0001; // play asynchronously
public static uint SND_FILENAME = 0x00020000; // name is file name
[DllImport("win……
[/Quote]
这个里面的"E:\音乐\周杰伦-东风破.mp3",我想用个变量把它传进去为什么不行啊?也就是:
string path="E:\音乐\周杰伦-东风破.mp3", mcisendstring(@"open"+path+"alias temp_alias",Null,0,0);
没有声音出来。请指教,谢谢。。。
lsd123 2009-03-03
  • 打赏
  • 举报
回复
.
  • 打赏
  • 举报
回复
我叼
太棒啦
我也赶紧试试
尽量吸收这知识
  • 打赏
  • 举报
回复
好的 谢谢大侠了。
zhaozhijun0207 2009-03-03
  • 打赏
  • 举报
回复
mciSendString(@"open " + Application.StartupPath + "\\Login.mp3 alias temp_alias", null, 0, 0);

我正在试相对路径呢,听不到声音了.
不知道哪里写错了,我


反正你的声音已经出来了,我就不讨论下面的了,我现在有工作要忙了
  • 打赏
  • 举报
回复
ok
我发现两个问题
一,在我的代码中是用。mp3结尾,
D盘的是MP3结尾
二,估计就是你所说的用字母代替汉字


大侠我再请教下
咱们的代码中用的路径是绝对路径
我想放到bin里的debug里
用相对路径应该怎么写呢?
  • 打赏
  • 举报
回复
好的 我在试试
  • 打赏
  • 举报
回复
我的耳麦也是好使用的
在调试时没有错误,也没异常。
但是就是没有声音
zhaozhijun0207 2009-03-03
  • 打赏
  • 举报
回复
从开始到现在.mp3

用字母来秘密音乐文件看看,比如Login.mp3
  • 打赏
  • 举报
回复
就这些了 其他的就不用了吧
  • 打赏
  • 举报
回复
program.cs
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace BackMusic
{
static class Program
{
/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
  • 打赏
  • 举报
回复
好的
form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using System.Runtime.InteropServices;



namespace BackMusic
{
public partial class Form1 : Form
{
public static uint SND_ASYNC = 0x0001; // play asynchronously
public static uint SND_FILENAME = 0x00020000; // name is file name
[DllImport("winmm.dll")]
public static extern uint mciSendString(string lpstrCommand,
string lpstrReturnString, uint uReturnLength, uint hWndCallback);


public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
     mciSendString(@"close temp_alias", null, 0, 0);
mciSendString(@"open ""D:\TDDOWNLOAD\从开始到现在.mp3"" alias temp_alias",
null, 0, 0);
mciSendString("play temp_alias repeat", null, 0, 0);
}
}
}
zhaozhijun0207 2009-03-03
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 LJH20002004200820131 的回复:]
我用的是vs2005日语版
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new frmMain用户登陆());
}
这句是自动生成吧?不需要添加到form.cs吧?
[/Quote]

自动生成



[Quote=引用 19 楼 LJH20002004200820131 的回复:]
namespace BackMusic
{
static class Program
{
/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());

[/Quote]
能否把这一窗体相关的代码全贴出来?[跟那个音乐相关的代码]
  • 打赏
  • 举报
回复
namespace BackMusic
{
static class Program
{
/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
我这个有问题吗?
  • 打赏
  • 举报
回复
命名空间我都添加了
  • 打赏
  • 举报
回复
我用的是vs2005日语版
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new frmMain用户登陆());
}
这句是自动生成吧?不需要添加到form.cs吧?
zhaozhijun0207 2009-03-03
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 ximi82878 的回复:]
请问下这个是第三方组件吗??我是个菜鸟。。。
[/Quote]
不是啊,都是vs2005自带的东东,vs2003我就不知道了
ximi82878 2009-03-03
  • 打赏
  • 举报
回复
请问下这个是第三方组件吗??我是个菜鸟。。。
zhaozhijun0207 2009-03-03
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 LJH20002004200820131 的回复:]
不好意思 我放到Load里和button里都加了 不好使
[/Quote]

不会啊,我的可以的

//
using System.Runtime.InteropServices;

namespace KySoft
{
public partial class frmMain用户登陆 : ImeForm
{
public static uint SND_ASYNC = 0x0001; //发挥异步
public static uint SND_FILENAME = 0x00020000;//名称是文件名
[DllImport("winmm.dll")]
public static extern uint mciSendString(string lpstrCommand, string lpstrReturnString, uint uReturnLength, uint hWndCallback);

public frmMain用户登陆()
{
InitializeComponent();
}

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new frmMain用户登陆());
}

private void frmMain用户登陆_Load(object sender, EventArgs e)
{
//登录时的背景音乐
mciSendString(@"close temp_alias", null, 0, 0);
mciSendString(@"open ""D:\KuGou2008\Lyric\m2.mp3"" alias temp_alias", null, 0, 0);
mciSendString("play temp_alias repeat", null, 0, 0);



你是不是没加using
  • 打赏
  • 举报
回复
不好意思 我放到Load里和button里都加了 不好使
加载更多回复(12)

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧