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