Bueno sigo con los experimentos
miren como queda esto.
Mañana si todo va bien subo un video explicativo y el código
Saludos.
Por cierto logre hacer funcionar la función que usa el código de Vuott, el problema radicaba en que no instale la librería adecuada, libtag_c que en mi sistema se llama libtagc0, un error mio
así que ahora funciona a la perfección
Les dejo el código, que es muy util para leer las bibliotecas enteras de archivos ya que es súper rápido, sorprendentemente rápido.
Por las pruebas que hice extrae bien los datos de largo den segundos de las canciones. Si alguno lo prueba por favor comente si todo va correcto.
Código:
Export
Library "libtag_c:0.0.0"
Public Struct TagLib_File
dummy As Integer
End Struct
Public Struct TagLib_Tag
dummy As Integer
End Struct
Public Struct TagLib_AudioProperties
dummy As Integer
End Struct
' void taglib_set_strings_unicode(BOOL unicode)
' By default all strings coming into or out of TagLib's C API are in UTF8.
' However, it may be desirable For TagLib To operate On Latin1(ISO - 8859 - 1) strings In which Case this should be set To FALSE.
Private Extern taglib_set_strings_unicode(unicode As Boolean)
' TagLib_File *taglib_file_new_type(const char *filename)
' Creates a TagLib file based on \a filename.
Private Extern taglib_file_new(filename As String) As TagLib_File
' TagLib_Tag *taglib_file_tag(const TagLib_File *file)
' Returns a pointer to the tag associated with this file.
Private Extern taglib_file_tag(_file As TagLib_File) As TagLib_Tag
' char *taglib_tag_title(const TagLib_Tag *tag)
' Returns a string with this tag's title.
Private Extern taglib_tag_title(tag As TagLib_Tag) As String
' char *taglib_tag_artist(const TagLib_Tag *tag)
' Returns a string with this tag's artist.
Private Extern taglib_tag_artist(tag As TagLib_Tag) As String
' char *taglib_tag_album(const TagLib_Tag *tag)
' Returns a string with this tag's album name.
Private Extern taglib_tag_album(tag As TagLib_Tag) As String
' unsigned int taglib_tag_year(const TagLib_Tag *tag)
' Returns the tag's year or 0 if year is not set.
Private Extern taglib_tag_year(tag As TagLib_Tag) As Integer
' char *taglib_tag_comment(const TagLib_Tag *tag)
' Returns a string with this tag's comment.
Private Extern taglib_tag_comment(tag As TagLib_Tag) As String
' unsigned int taglib_tag_track(const TagLib_Tag *tag)
' Returns the tag's track number or 0 if track number is not set.
Private Extern taglib_tag_track(tag As TagLib_Tag) As Integer
'Private Extern taglib_tag_encoder(tag As TagLib_Tag) As String
'Private Extern taglib_tag_volume_number(tag As TagLib_Tag) As Integer
' char *taglib_tag_genre(const TagLib_Tag *tag)
' Returns a string with this tag's genre.
Private Extern taglib_tag_genre(tag As TagLib_Tag) As String
' const TagLib_AudioProperties *taglib_file_audioproperties(const TagLib_File *file)
' Returns a pointer to the the audio properties associated with this file.
Private Extern taglib_file_audioproperties(_file As TagLib_File) As TagLib_AudioProperties
' int taglib_audioproperties_length(const TagLib_AudioProperties *audioProperties)
' Returns the length of the file in seconds.
Private Extern taglib_audioproperties_length(audioProperties As TagLib_AudioProperties) As Integer
' int taglib_audioproperties_bitrate(const TagLib_AudioProperties *audioProperties)
' Returns the bitrate of the file in kb/s.
Private Extern taglib_audioproperties_bitrate(audioProperties As TagLib_AudioProperties) As Integer
' int taglib_audioproperties_samplerate(const TagLib_AudioProperties *audioProperties)
' Returns the sample rate of the file in Hz.
Private Extern taglib_audioproperties_samplerate(audioProperties As TagLib_AudioProperties) As Integer
' int taglib_audioproperties_channels(const TagLib_AudioProperties *audioProperties)
' Returns the number of channels in the audio stream.
Private Extern taglib_audioproperties_channels(audioProperties As TagLib_AudioProperties) As Integer
' void taglib_tag_free_strings(void)
' Frees all of the strings that have been created by the tag.
Private Extern taglib_tag_free_strings()
' void taglib_file_free(TagLib_File *file)
' Frees and closes the file.
Private Extern taglib_file_free(_file As TagLib_File)
Public Function Info(fileaudio As String) As Collection
Dim fl As TagLib_File
Dim autag As TagLib_Tag
Dim auprop As TagLib_AudioProperties
' Dim secondi, minuti As Integer
'
Dim inf As New Collection
taglib_set_strings_unicode(False)
taglib_set_strings_unicode(True)
fl = taglib_file_new(fileaudio)
If IsNull(fl) Then Error.Raise("Impossibile caricare il file audio: " & fileaudio)
autag = taglib_file_tag(fl)
If IsNull(autag) Then Error.Raise("Impossibile ottenere i tag dal file audio: " & fileaudio)
inf.Add(taglib_tag_album(autag), "Album")
inf.Add(taglib_tag_artist(autag), "Artist")
inf.Add(taglib_tag_track(autag), "Track")
inf.Add(taglib_tag_title(autag), "Title")
inf.Add(taglib_tag_year(autag), "Year")
inf.Add(taglib_tag_genre(autag), "Genre")
inf.Add(taglib_tag_comment(autag), "Comment")
' Mostra le proprietà del file audio:
auprop = taglib_file_audioproperties(fl)
If IsNull(auprop) Then
inf.Add(True, "AudioError")
Else
inf.Add(taglib_audioproperties_length(auprop), "Length")
inf.Add(taglib_audioproperties_bitrate(auprop), "Bitrate")
inf.Add(taglib_audioproperties_samplerate(auprop), "Frequency")
inf.Add(taglib_audioproperties_channels(auprop), "Channels")
Endif
' Va in chiusura:
taglib_tag_free_strings()
taglib_file_free(fl)
Return inf
End
No recuerdo si funcionaba para ogg y flac pero para mp3 si.
Saludos.