Giter Site home page Giter Site logo

taglib-sharp-portable's Introduction

TagLib#.Portable

Build

IMPORTANT - PLEASE READ

The mono/taglib-sharp project has since updated to .NET Standard and is more maintained than this one. The history of this was originally bringing a portable version across Silverlight, Framework, and other targets where Mono wasn't doing that at the time. It appears that project is being maintained now and you should strongly evaluate whether that one is better for you...it likely is 😉

Project Information

This is a fork of the popular TagLib# project.

TagLib is a library for reading and editing the meta-data of several popular audio formats. Currently it supports both ID3v1 and ID3v2 for MP3 files, Ogg Vorbis comments and ID3 tags and Vorbis comments in FLAC, MPC, Speex, WavPack TrueAudio, WAV, AIFF, MP4 and ASF files.

This is re-implemented as a .NET Standard (1.6) library that can be used by several .NET platforms. See https://docs.microsoft.com/en-us/dotnet/standard/net-standard for compatibility.

This is a work in progress and there are still some things needed to be done (see issues list).

Key Changes

Perhaps the biggest change is the removal of LocalFileAbstraction, which in TagLib# was the default when reading a file into the library. This was done to maximize portability without trying to do some fancy hoop-jumping to isolated a portable storage mechanism. A StreamFileAbstraction was added and could easily be used as the primary mechanism in the various File.Create methods used to read in a file.

Installation

If you clone and build from source, from a VS command prompt just type build. You can also get the most current version from NuGet directly.

Sample Usage

To read in an MP3 file (using WinRT as an example):

// assume you've got to the point where you have a StorageFile 
// via a file picker or something similar

var fileStream = await (StorageFile)file.OpenStreamForReadAsync();

var tagFile = TagLib.File.Create(new StreamFileAbstraction(file.Name,
				 fileStream, fileStream);

var tags = tagFile.GetTag(TagTypes.Id3v2);

Debug.WriteLine(tags.Title);

There are other ways you can do this as well and this is just a simplest example.

History

For some brief history, please read http://timheuer.com/blog/archive/2014/05/23/porting-taglib-sharp-to-portable-class-library.aspx.

taglib-sharp-portable's People

Contributors

haroldma-zz avatar mrcsharp22 avatar timheuer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

taglib-sharp-portable's Issues

Can not read tag in Xamarin

I use taglib-sharp-portable in Xamarin .

private async Task GetInfo(string file ,string name)
{
using (FileStream SourceStream = System.IO.File.Open(file, FileMode.Open))
{
byte[] result = new byte[SourceStream.Length];
await SourceStream.ReadAsync(result, 0, (int)SourceStream.Length);
Stream stream = new MemoryStream(result);
var tagFile = TagLib.File.Create(new StreamFileAbstraction(name, stream, stream));
var tags = tagFile.GetTag(TagTypes.Id3v2);
//string album = tags.Album;
return tags;
}
}

It tell me TagLib.Flac.File not found ...... I think I import TabLib Sharp Portable in nuget.All it is right .
But Why It give me this error
screen shot 2016-12-16 at 9 00 57 pm

Make it clear from which TagLib# version this fork is.

Maybe i'm missing it somewhere, but this is a fork from mono/taglib-sharp, correct? The info i'm missing is from which version you forked. Is it the latest public release? That's 2.1.0.0.

To further question on this; is there any chance you will be merging commits from mono/taglib-sharp to this fork, that project is reviving since @Starwer is taking some lead in it.

Check if id3 tags are readable (and not corrupted)

Hello, i'm using your library on a music app project for xamarin android and i need to check a tag for all music file of the device but if the user have a corrupted file on the device, the app crash with this exception:

TagLib.CorruptFileException: MPEG audio header not found.

Could you create a way to check if the file is corrupted or just return null to all tag and not stop the app.

Thanks for your time and attention.
Great library btw.

Recursion in File.cs AccessMode setter

In File.cs the setter ends with Mode = value at line 441. It creates a recursion. Setting Mode to value is useless since the getter checks the stream to return the mode. This problem leads to a stack overflow on some files, when there is a problem and the stream cannot be opened, so the access mode remains Closed and then a recursion occurs until the stack crashes.

Writing tags

Hi! I am experiencing one problem while writing tags using taglib sharp portable in my winRT app. Writing works, but it takes 20 seconds to finish and app is frezzed during that time. Is this a bug or I am doing something wrong??? I will really appreciate any help!

Cannot read MP4 file tag

I'm running this code, inspired by the sample:

Imports System.IO
Imports TagLib

<TestClass>
Public Class TagLibTests
  <TestMethod>
  Public Sub SetMp4TagTest()
    Dim oFile As TagLib.File
    Dim sPath As String
    Dim oTag As Tag

    sPath = "V:\Video.mp4"

    Using oStream As New FileStream(sPath, FileMode.Open)
      oFile = TagLib.File.Create(New StreamFileAbstraction(sPath, oStream, oStream))
      oTag = oFile.GetTag(TagTypes.Id3v2)

      Debug.WriteLine(oTag.Title)
    End Using
  End Sub
End Class

When this runs, oTag is always Nothing. I've tried TagTypes.Id3v1 and TagTypes.MovieId, to no avail.

Am I missing something?

File.Save() takes minutes to finish when writing tags to a 16.5MB mp3 file

Hello everyone, months ago issue #13 detailed how File.Save() would take around 20 seconds to complete. Today, i finally got to witness it in my new app. The mp3 file is 16.5MB and takes about 3-4 minutes to finish writing the tags. A similar file with 4.4MB needs only 2 seconds to finish.

I went through the code and found that inside the File.Insert (ByteVector data, long start, long replace) method, the File.RemoveBlock(long, long) is the one causing this huge delay. At first i thought this was due to the small buffer size (1024) so i changed it to (4096) but still had the same issue.
From what i understood from that code is that the remove block helps in getting rid of the extra bytes remaining in the file after writing a smaller tag than the previous one.

I am trying to solve this issue but with no luck. If anyone has any info that might help, please share it here so we can solve this.

Edit: #12 is a similar case

'Illegal characters in path.' exception in XmpTag.cs

I get the 'Illegal characters in path.' exception when creating an instance of TagLib.Gif.File object for some GIF files in the samples directory. The exception comes from the line 268 in XmpTag.cs file. When I replace
XDocument.Load(data) with XDocument.Parse(data)
this exception goes away.
However, a new exception, 'Cannot change named node' is raised in the ParseRDF function in line 302, when setting top.Name = attr.Value.
The Name property setter in XmpNode.cs explicitly forbids changing a name field in the case of a non-null value, so it's unclear why is it written like this. Changing the line
if (name != null)
to
if (!String.IsNullOrWhiteSpace(name))
seems to solve this.

Problem when saving

(1) Some files took a lot of time when saving even in small size files.
(2) When you add lyrics to an existing tag but without lyrics it will also take a lot of time.

tagFile.Save();

This line of code (tagFile.Save();) needs around 20-30 seconds to execute in my UWP app... Any help would be much appreciated...Thank you!

                    try
                    {
                        var writeStream = await file.OpenAsync(FileAccessMode.ReadWrite);
                        var tagFile = TagLib.File.Create(new StreamFileAbstraction(file.Name, writeStream.AsStreamForRead(), writeStream.AsStreamForWrite()));
                        var tag = tagFile.Tag;
                        tag.AlbumArtists = new string[] { artistName };
                        tag.Title = fileName;
                        tag.Album = albumName;
                        tagFile.Save();
                        tagFile.Dispose();
                        writeStream.Dispose();
                    }
                    catch
                    {

                    }

Port test suite

Need to complete the test suite porting and get tests green

Stackoverflow Exception When Saving

Hello,
I am currently writing a Windows Store (and Phone 8.1) app using your Taglib-Sharp fork. I create the File object using:

            var fileStream = await _tagFileService.File.OpenAsync(FileAccessMode.ReadWrite);
            file = TagLib.File.Create(new StreamFileAbstraction(_tagFileService.File.Name, fileStream.AsStream(), fileStream.AsStream()));
            Tags = file.GetTag(TagTypes.Id3v2);

Then i call file.Save() after modifying it and I get a stackoverflow exception.

MPEG 4 Album Art

The library isn't parsing pictures inside *.m4a files (ALAC or AAC codec)

License...

Can your library be used under the MIT license? Is it possible to use static linking?

Exception thrown by save() method but changes are persisted

I'm working on an UWP (Visual Studio Tools For UWP 14.0.25527.01. TagLib.Portable 1.0.3. from NuGet). My app get songs stored in Music Library and adds tags to them. The problem is each time I call to tagLibFile.save() it throws an exception: "The system cannot find the file specified. (Exception from HRESULT: 0x80070002)":null}"

This is the code I actually use:

`StorageFolder musicFolder = KnownFolders.MusicLibrary;
songStorageFile = await musicFolder.GetFileAsync("songTest.mp3");
var stream = await songStorageFile.OpenStreamForWriteAsync();

TagLib.Id3v2.Tag.DefaultVersion = 3;
TagLib.Id3v2.Tag.ForceDefaultVersion = true;

var tagFile = TagLib.File.Create(new StreamFileAbstraction(songStorageFile.Name, stream, stream));
var tags = tagFile.GetTag(TagTypes.Id3v2);
tags.Title = "my custom title";

tagFile.Save();`

The craziest thing is despite of the exception, once I close the app debug the original file is updated with all changes.

Also, with a breakpoint, I have checked songStorageFile, stream and tagFile vars and they're correctly loaded (they points ok to the file).

This errors occurs me in Windows 10 and Windows 10 Mobile (Lumia 640).

Get id3v2 tags from url

Is it possible to download only the neccessary bytes to create the tags from an url?
I'm trying to parse all my id3v2 tags in my google drive and I don't want to have to download every file first

ID3 Tags With Multiple Fields Not Being Extracted

The attached MP3 file was tagged using MP3Tag. For the Composer Tag, there were two (2) names entered. Only the first name for the TCOM tag is extracted. I examined the file and the 2 names are present, however separated by a null. Can TAGLIB be modified to check tags for multiple items? With MP3TAG, most text fields (string) may have multiple items per entry.

Thanks in advance for looking into this issue.

05 - Albéniz - Granada - Test.zip

Jerry B

Getting every available tag values

Is there a way to get a Map of every tag key and value inside a song file? In the C version it is possible to use PropertyMap, but that class doesn't exist here

can not read the rating property in PopularimeterFrame

Hello,

I want change the rating property.
Dim PopM As TagLib.Id3v2.PopularimeterFrame = TagLib.Id3v2.PopularimeterFrame.Get(tags, "Windows Media Player 9 Series", False)
I use this code and it works but I don't know ever the user. How I get the user or is there a other way to change the rating.

Better error reports when passing an invalid name to File.Create

I got this cryptic error the first time I tried to use File.Create:

An exception of type 'TagLib.UnsupportedFormatException' occurred in TagLib.Portable.dll but was not handled in user code

Additional information: streamname (taglib/)

I had to dig a little bit until I found that TagLib requires me to add an extension to the stream name if the mimetype is missing (https://github.com/timheuer/taglib-sharp-portable/blob/master/src/TagLib.Shared/TagLib/File.cs#L1264).

I'm not really sure why we ask for a stream name (other than guessing a mimetype), but it would be great if this behavior was documented somewhere or the error was more explicit.

I'm thinking something like the following could work:

                if(index >= 1 && index < abstraction.Name.Length)
                    ext = abstraction.Name.Substring (index,
                        abstraction.Name.Length - index);

                if (string.IsNullOrWhiteSpace(ext))
                    throw new UnsupportedFormatException (
                        String.Format (
                            CultureInfo.InvariantCulture,
                            "If a mimetype is not specified, then the IFileAbstraction name should have a file extension"));

                mimetype = "taglib/" + ext.ToLower();

Thanks!

How to add album art?

Hi there! I am trying to use this library in my UWP app. I know how to add the album, artists, and other text tags. However, when I try to assign the album art from a .jpg file, the music file's album art remains empty when I reproduce it using Windows Media Player.
How should I do it?
Thanks!

TagLib.Riff.InfoTag doesn't allow setting Album

Other properties like AlbumArtists, Genres, Title work just fine but setting Album for TagLib.Riff.InfoTag (wave file) has no effect and Album remains null no matter what you assign to it.
Using TagLib.Portable v1.0.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.