B4J Question [SOLVED ] Audio File Properties

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
#AdditionalJar: mp3agic-0.9.1
Sub Process_Globals
    
End Sub

Sub AppStart (Args() As String)
    Log("Hello world!!!")
    Dim mp3 As JavaObject = LoadMp3File("D:\Documents\Music\222.mp3")
    Log(mp3.RunMethod("getBitrate", Null))
    Log(mp3.RunMethod("getSampleRate", Null))
    Log(mp3.RunMethod("getLengthInMilliseconds", Null))
End Sub

Private Sub LoadMp3File (Path As String) As JavaObject
    Dim jo As JavaObject
    jo.InitializeNewInstance("com.mpatric.mp3agic.Mp3File", Array(Path))
    Return jo
End Sub


Jar: https://repo1.maven.org/maven2/com/mpatric/mp3agic/0.9.1/mp3agic-0.9.1.jar
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Thank you
 
Upvote 0

CR95

Active Member
Licensed User
By reading the detailed description of the library, I found that it was possible also to get the frames of the MP3 track
I tried something like that :
B4X:
ID2 = mp3.RunMethod("hasId3v2Tag", Null)
If ID2 = True Then
    Dim ListMP3 As Object
    ListMP3 = "getTrack"
    CurTrackTitre = mp3.RunMethod("getId3v2Tag", ListMP3)
    Log ("TitreMP3= " & CurTrackTitre)
EndIf
But I get an error.
Please could you help to get the data from the tag
 
Upvote 0

CR95

Active Member
Licensed User
Final target is to get the parameters from the ID (name, year, album....)
In the sample joined to the library, the author gets them by getting :
- firstly, id3v2Tag = mp3file.getId3v2Tag();
- secondly, the parameter from this tag = id3v2Tag.getTrack());
I tried to reproduce that by calling Erel's subroutine with "getTrack" as parameter.
As I said, it was a try ! I do not know Java world
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…