TagLib を使用して、IsolatedStorage に保存されている mp3 ファイルのメタデータを読み込もうとしています。TagLib は通常、入力としてファイル パスのみを使用することは知っていますが、WP はサンドボックス環境を使用するため、ストリームを使用する必要があります。
このチュートリアル ( http://www.geekchamp.com/articles/reading-and-writing-metadata-tags-with-taglib ) に従って、iFileAbstraction インターフェイスを作成しました。
public class SimpleFile
{
public SimpleFile(string Name, Stream Stream)
{
this.Name = Name;
this.Stream = Stream;
}
public string Name { get; set; }
public Stream Stream { get; set; }
}
public class SimpleFileAbstraction : TagLib.File.IFileAbstraction
{
private SimpleFile file;
public SimpleFileAbstraction(SimpleFile file)
{
this.file = file;
}
public string Name
{
get { return file.Name; }
}
public System.IO.Stream ReadStream
{
get { return file.Stream; }
}
public System.IO.Stream WriteStream
{
get { return file.Stream; }
}
public void CloseStream(System.IO.Stream stream)
{
stream.Position = 0;
}
}
通常、私はこれを行うことができます:
using (IsolatedStorageFileStream filestream = new IsolatedStorageFileStream(name, FileMode.OpenOrCreate, FileAccess.ReadWrite, store))
{
filestream.Write(data, 0, data.Length);
// read id3 tags and add
SimpleFile newfile = new SimpleFile(name, filestream);
TagLib.Tag tags = TagLib.File.Create(newfile);
}
問題は、TagLib.File.Create がまだ SimpleFile オブジェクトを受け入れたくないということです。どうすればこれを機能させることができますか?