MP3从两个人创造了不会在WMP11播放? [英] MP3 created from two others won't play in WMP11?

查看:119
本文介绍了MP3从两个人创造了不会在WMP11播放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

test1.mp3和test2.mp3具有相同的比特率和采样率,和我想要在HTTP响应合并它们。得到的文件是请将test.mp3。

请将test.mp3起着WMP12和VLC罚款。在WMP11,我只听到这些来自test1.mp3音频。此刻的你希望听到test2.mp3的音频的开始,玩家停止播放。 WMP11报告没有任何错误...它只是停止播放。

需要改变什么,这样请将test.mp3将在WMP11正常播放?

 保护无效的Page_Load(对象发件人,EventArgs的发送){
    Response.Clear();
    Response.ContentType =音频/ MPEG
    Response.AddHeader(内容处置,附件;文件名=请将test.mp3);
    VAR bytes1 = System.IO.File.ReadAllBytes(@C:\\ test1.mp3);
    WriteBytesToResponse(bytes1);
    VAR字节2 = System.IO.File.ReadAllBytes(@C:\\ test2.mp3);
    WriteBytesToResponse(字节2);
    到Response.End();
}私人无效WriteBytesToResponse(字节[] sourceBytes){
    使用(VAR的SourceStream =新的MemoryStream(sourceBytes,FALSE)){
        sourceStream.WriteTo(Response.OutputStream);
    }
}


解决方案

MP3文件包含完整的MPEG1头,其中包括信息,如流的长度。你根本无法将它们连接起来。 WMP读取头,所确定的重放长度,并且当所述第一文件完成停止。该数据的其余部分被忽略,因为它不应该存在。

您将需要使用一些库或工具,它了解MPEG1或MP3文件做串联。

test1.mp3 and test2.mp3 have the same bitrate and sample rate, and I'm trying to merge them in an HTTP response. The resulting file is test.mp3.

test.mp3 plays fine in WMP12 and VLC. In WMP11, I hear only the audio which came from test1.mp3. At the moment you expect to hear the beginning of test2.mp3's audio, the player stops playing. WMP11 reports no errors... it just stops playing.

What needs to change such that test.mp3 will play correctly in WMP11?

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);
    }
}

解决方案

MP3 files contain a full MPEG1 header, amongst other information, such as the stream length. You simply cannot concatenate them. WMP read the header, determined the playback length, and stops when the first file is done. The rest of the data is ignored as it shouldn't be there.

You will need to use some library or utility which understands MPEG1 or MP3 files to do the concatenation.

这篇关于MP3从两个人创造了不会在WMP11播放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆