BeautifulPilgrim / MauiAudio

MIT License
23 stars 5 forks source link

Image local file #11

Open jcljb opened 1 year ago

jcljb commented 1 year ago

Hello, could it be possible to specify a local image file or retrieve image in metadata of a music local file (p. for Android ptf) ?

BeautifulPilgrim commented 1 year ago

ok, I will try

YBTopaz8 commented 4 months ago

You can read music files and get the data (and images) with this library https://github.com/Zeugma440/atldotnet Like this

byte[]? GetCoverImage(string filePath)
{
    var LoadTrack = new Track(filePath);
    if (LoadTrack.EmbeddedPictures.Count != 0)
    {
        return LoadTrack.EmbeddedPictures[0].PictureData;
    }
    else
    {
        string directoryPath = Path.GetDirectoryName(filePath);
        var jpgFiles = Directory.GetFiles(directoryPath, "*.jpg", SearchOption.TopDirectoryOnly);
        if (jpgFiles.Length > 0)
        {
            return File.ReadAllBytes(jpgFiles[0]);
        }            
    }
    return null;
}
jcljb commented 4 months ago

Thanks, i will try too