[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to read artwork bitmaps embedded in MP3 files as "image"-Tag


Am 10.03.26 um 02:44 schrieb Benoît Minisini:
I added in the last commit support for GStreamer "sample" objects, through a new 'MediaSample' class.

The image tag returns such an object, that includes the image contents (returned by the 'Data' property), and some metadata (returned by the 'Info' property).

That metadata is returned as a collection of collections. The contents of these collections can be anything.

In the case of the mp3 I used for testing (not yours), I get that:

{"image/jpeg":{"width":400,"height":400,"sof-marker":2}}

It seems to mean that the image is a JPEG, so you have to use the 'Image.FromString()' method to transform the sample data into an Image object.

Try it and tell me if you have any problem.

Hi Benoît!

Thanks a lot for your attention in this matter.

It works for the image tag, but it doesn't allow to access the TagList-Data any longer. The TagList-Collection now always returns an object instead of a string. So my demo app is now crashing at

TextArea1.text &= TagList[sTag]

These tag Strings are certainly used in most Gambas media applications out there.

This is what I did:

Public Sub PipeEvents_Tag(TagList As MediaTagList)

  For Each sTag As String In Taglist.Tags
     If sTag = "image" Then
       Print "Info: "; TagList[sTag].Info
       Print "Type: "; TypeOf(TagList[sTag].Info)
       Print "Size: "; TagList[sTag].Size
       PictureBox1.Image = Image.FromString(TagList[sTag].Data)
    else
        'TextArea1.text &= TagList[sTag]     '<--- OUT-COMMENTED BECAUSE THE APP IS NOW CRASHING HERE
    Endif
  Next

End

I hope you have an idea to get this backwards compatible with existing code out there (in best case). If not (which would be OK for me) ... how about new Text Property in the MediaSample class? Deliver any text via the Data Property of the new MediaSample-Class?

In case of an image tag, the Info-property in my case returns "(Collection 0x58fd8b0c2918)" and a test showed that this data type is 16. So it seems that we have a new data type in Gambas - correct? I would have expected a String under the title "Info". As the info-property is supposed to be a collection of collections - how could this object be enumerated - and would there be any use by doing this? I am further wondering why (and how) you got "{"image/jpeg":{"width":400,"height":400,"sof-marker":2}}" in your project.

Best regards, Claus












Follow-Ups:
Re: How to read artwork bitmaps embedded in MP3 files as "image"-TagBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
References:
How to read artwork bitmaps embedded in MP3 files as "image"-TagClaus Dietrich <claus.dietrich@xxxxxxxxxx>
Re: How to read artwork bitmaps embedded in MP3 files as "image"-TagClaus Dietrich <claus.dietrich@xxxxxxxxxx>
Re: How to read artwork bitmaps embedded in MP3 files as "image"-TagClaus Dietrich <claus.dietrich@xxxxxxxxxx>
Re: How to read artwork bitmaps embedded in MP3 files as "image"-TagBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>