Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3755

Declare help, reading media tags

$
0
0

Hi all, I’m trying to read mp3 tags, I’ve tried declares with no joy, here is the code, can anyone fix it ?..

dim mp3FilePath as CString = “/path /to /mp3 file/”

Declare Function MediaMetadataRetriever Lib “android.media” () As Ptr
Declare Sub setDataSource Lib “android.media.MediaMetadataRetriever” (retriever As Ptr, path As cString)
Declare Function extractMetadata Lib “android.media.MediaMetadataRetriever” (retriever As Ptr, keyCode As Int32) As cString
Declare Sub releaseMediaMetadataRetriever Lib “android.media.MediaMetadataRetriever” (retriever As Ptr)

’ Constants for metadata keys
Const METADATA_KEY_TITLE As Int32 = 7
Const METADATA_KEY_ARTIST As Int32 = 2
Const METADATA_KEY_ALBUM As Int32 = 1
Const METADATA_KEY_DURATION As Int32 = 9

’ Method to access MP3 media tags
'Function GetMP3Tags(mp3FilePath As String) As Dictionary
Dim tags As New Dictionary

’ Create a new instance of MediaMetadataRetriever
Dim retriever As Ptr = MediaMetadataRetriever()

Try
’ Set the data source to the MP3 file
setDataSource(retriever, mp3FilePath)

’ Retrieve various MP3 tags
Dim title As String = extractMetadata(retriever, METADATA_KEY_TITLE)
Dim artist As String = extractMetadata(retriever, METADATA_KEY_ARTIST)
Dim album As String = extractMetadata(retriever, METADATA_KEY_ALBUM)
Dim duration As String = extractMetadata(retriever, METADATA_KEY_DURATION)

’ Store the retrieved tags in the dictionary
tags.Value(“title”) = title
tags.Value(“artist”) = artist
tags.Value(“album”) = album
tags.Value(“duration”) = duration

Catch e As RuntimeException
’ Handle exceptions
MessageBox("Error: " + e.Message)
End Try

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 3755

Trending Articles