EDIT: Oh..... I lied! The commandline fails if the two source files have different bitrates (does samplerate matter?). Also, the source code below succeeds when the two sources are the same bitrate. So, this looks like a bitrate challenge now. Hrm....
Original question:
result.mp3 (from the commandline, below) is playable in WMP11.
The ASP.NET code below serves a file which plays fine in WMP11. But, when I uncomment those two lines, WMP11 won't play the file. Something about the code that merges the two MP3 files isn't to the satisfaction of WMP11.
How can I change the ASP.NET code to merge the two MP3s in the HTTP response with the success that the 'copy' commandline gives me?
protected void Page_Load(object sender, EventArgs e) {
Response.Clear();
Response.ContentType = "audio/mpeg";
Response.AddHeader("Content-Disposition", "attachment; filename=test.mp3");
var bytes1 = System.IO.File.ReadAllBytes(@"C:\test1.mp3");
WriteBytesToResponse(bytes1);
//var bytes2 = System.IO.File.ReadAllBytes(@"C:\test2.mp3");
//WriteBytesToResponse(bytes2);
Response.End();
}
private void WriteBytesToResponse(byte[] sourceBytes) {
using (var sourceStream = new MemoryStream(sourceBytes, false)) {
sourceStream.WriteTo(Response.OutputStream);
}
}
copy /B test1.mp3+test2.mp3 result.mp3