1
我试图播放一个mp3文件,它嵌入在我的c#应用程序(winforms)中,但没有结果。我不想从资源创建文件并播放它。我搜索了互联网,但没有找到任何工作示例。他们都从资源创建一个文件并保存,然后将文件路径传递给mci或wmp。是否有可能传递一个流?播放嵌入式资源mp3文件
public partial class Form1 : Form
{
[DllImport("winmm.dll")]
private static extern long mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback);
public Form1()
{
InitializeComponent();
Stream fileStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("mymp3.mp3");
string command = "open" + fileStream not filePath + "type MPEGVideo alias MyMp3";
mciSendString(command, null, 0, 0);
command = "play MyMp3";
mciSendString(command, null, 0, 0);
}
}
在此先感谢
然后你如何使用这个'filestream'? – ChrisF
我已更新我的代码,我想使用流而不是文件路径。命令不会是一个字符串,我猜。 – mjekov