【问题标题】:How to merge MP3 files in WP8 (edit)如何在 WP8 中合并 MP3 文件(编辑)
【发布时间】:2014-02-03 16:44:01
【问题描述】:

我有一个 MP3 文件列表,我想将它们合并到一个文件中。我将文件本地下载到隔离存储中,但我不知道如何合并它们。谷歌也没有帮助。我不知道它是否可能在 WP8 中。 (2) 如果不可能的话,你可以建议什么具体的解决方案(我的文件也在网上)。

我在下面写了合并代码,但这总是写最后一个文件。

string[] files = new string[] { "001000.mp3", "001001.mp3", "001002.mp3", "001003.mp3", "001004.mp3", "001005.mp3", "001006.mp3", "001007.mp3" };

using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
    string newFileName = "001.mp3";
    foreach (string _fileName in files)
    {
        if (storage.FileExists(_fileName))
        {
            byte[] bytes = new byte[1];
            using (var f = new IsolatedStorageFileStream(_fileName, FileMode.Open, storage))
            {
                bytes = new byte[f.Length];
                int byteCount;
                using (var isfs = new IsolatedStorageFileStream(newFileName, FileMode.OpenOrCreate, storage))
                {
                    while ((byteCount = f.Read(bytes, 0, bytes.Length)) > 0)
                    {
                        isfs.Write(bytes, 0, byteCount);
                        isfs.Flush();
                    }
                }
            }
        }
    }
}

如何将文件添加(合并)到新创建文件的末尾?

【问题讨论】:

标签: c# windows-phone-8 merge mp3


【解决方案1】:

我在写入文件之前添加了isfs.Seek(0, SeekOrigin.End);。这就是我们可以简单地合并相同比特率的 mp3 文件的方法。

代码如下:

using (var isfs = new IsolatedStorageFileStream(newFileName, FileMode.OpenOrCreate, storage))
{
    isfs.Seek(0, SeekOrigin.End); //THIS LINE DID SOLVE MY PROBLEM
    while ((byteCount = f.Read(bytes, 0, bytes.Length)) > 0)
    {
        isfs.Write(bytes, 0, byteCount);
        isfs.Flush();
    }
}

如果我的代码看起来更长,请改进它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-14
    • 1970-01-01
    • 1970-01-01
    • 2015-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多