1

WindowsStoreプロジェクトでTagLibを使用したいのですが。TagLibは、そのdll(taglib-sharp.dll)とともに参照としてインポートされます。機能がチェックされているため、音楽フォルダー内の任意のファイルにアクセスできます。しかし、私が電話すると

TagLib.File file = TagLib.File.Create(soundFilePath, TagLib.ReadStyle.None); 

次のエラーがスローされます。

System.UnauthorizedAccessException was unhandled by user code
HResult=-2147024891
Message=Access to the path 'C:\Users\Gabor\Music\_FIFA 2010 soundtracks\01. Meine Stadt - Auletta.mp3' is denied.
Source=taglib-sharp
StackTrace:
   at TagLib.File.Create(IFileAbstraction abstraction, String mimetype, ReadStyle propertiesStyle)
   at TagLib.File.Create(String path, String mimetype, ReadStyle propertiesStyle)
   at TagLib.File.Create(String path, ReadStyle propertiesStyle)
4

3 に答える 3

3

TagLibSharpを使用して、StreamFileAbstractionを作成し、それをFile.Createに渡すことで、タグをロードできます。これは禁止されているAPIを使用しません。

public void ExampleCall(StorageFile storageFile)
{
    IRandomAccessStreamWithContentType f = await storageFile.OpenReadAsync();
    var file = File.Create(new StreamFileAbstraction(storageFile.Name, f.AsStream()));
}

public class StreamFileAbstraction : File.IFileAbstraction
{
    public StreamFileAbstraction(string name, Stream stream)
    {
        Name = name;
        ReadStream = stream;
        WriteStream = stream;
    }

    public void CloseStream(Stream stream)
    {
        stream.Flush();
    }

    public string Name { get; private set; }
    public Stream ReadStream { get; private set; }
    public Stream WriteStream { get; private set; }
}
于 2012-12-30T23:11:58.610 に答える
0

このようにそれを行うことができませんでした。代わりにMusicPropertiesを使用し、次にlastfm apiを使用して必要な情報を取得しました。Win8c#では非常に難しいので、通常のC#では簡単です。

于 2012-11-16T19:28:09.717 に答える
0

WinRTの場合、次に必要なものは次のとおりです。

var task = await StorageFile.GetFileFromApplicationUriAsync(uri);
var stream = await task.OpenStreamForReadAsync();
 using (var info = File.Create(new StreamFileAbstraction(Path.GetFileName(uri.LocalPath), stream, stream)))
 {
      Album = info.Tag.Album;
      Comment = info.Tag.Comment;
      // more properties
 }

NuGetパッケージを追加する必要があります-TagLib#Portable

于 2015-03-10T22:32:59.347 に答える