Public Sub GetInfo(filepath As String)
Dim sOutput As String
Dim aScan As String[]
Dim NomeFile As String
Dim Anno As String
Dim Appoggio As Integer
Try Player_A.Close
Player_A = New MediaPlayer As "MediaPlayer"
'se vuoi riprodurre il media nell'ambiente VERO usa questo
'UscitaAudio = New MediaControl(Player_A, "ximagesink")
'senno' per sveltire si puo' usare un FAKE sink
'UscitaAudio = New MediaControl(Player_A, "fakesink")
NomeFile = File.BaseName(filepath)
Select Case LCase(File.Ext(filepath))
Case "mp3"
'prova ad estrarre i dati dai TAG mp3
TAG_mp3.lettura(filepath)
'controllo se i dati sono presenti e semmai li estraggo dalla struttura del nome della canzone
'---ANNO---- (prima facevo con 'Exec ["mp3info", "-p", "%y", filepath] To sOutput
If Mp3_Tag_anno <> "" Then 'se ci sono informazioni nell'ID3 tag
TextBox_year.Text = Mp3_Tag_anno
Else 'altrimenti dal nome del file (tra parentesi l'anno)
anno = Mid(NomeFile, InStr(nomefile, "(") + 1)
anno = Mid(anno, 1, InStr(anno, ")") - 1)
Try appoggio = CInt(anno)
If Error Then
TextBox_year.Text = Year(Date)
Else
TextBox_year.Text = appoggio
Endif
'dopo di che elimino l'eventuale anno dal nome del file
nomefile = Replace(nomefile, "(" & TextBox_year.Text & ")", "")
Endif
'--- ARTISTA --- (prima facevo con ' Exec ["mp3info", "-p", "%a", filepath] To sOutput
If Mp3_Tag_artista <> "" Then 'con dati nell'ID3 tag
TextBox_artist.Text = Mp3_Tag_artista
Else 'altrimenti dal nome del file (prima parte e' l'autore
TextBox_artist.Text = Trim(Mid(NomeFile, 1, InStr(nomefile, " - ") - 1))
Endif
'--- TITOLO della canzone --- (prima facevo con ' Exec ["mp3info", "-p", "%t", filepath] To sOutput
If Mp3_Tag_titolo <> "" Then 'dall'ID3 tag
TextBox_title.Text = Mp3_Tag_titolo
Else 'oppure dal file name .... quello rimanente dopo il trattino e' il titolo del pezzo
TextBox_title.Text = Trim(Mid(NomeFile, InStr(nomefile, " - ") + 2))
Endif
'--- DURATA della canzone --- (prima usavo ' Exec ["mp3info", "-p", "%S", filepath] To sOutput
If Mp3_Tag_lunghezza <> "" Then 'dall'ID3 tag
Label_Duration.Text = Time(0, 0, CInteger(Mp3_Tag_lunghezza))
Else 'oppure dalle proprieta' del lettore
Player_A.URL = Media.URL(filepath)
Try Player_A.Play
If Error Then
Debug Error.Text & " on " & filepath
Else
While Player_A.Duration = 0
Wait 0.1
Wend
Endif
Label_Duration.Text = HMS_From_Seconds(CString(Player_A.Duration))
Player_A.Stop
Player_A.Close
End If
Label_EntryIN.Text = "00:00:00"
Label_EntryOUT.Text = Label_Duration.Text
Label_DJ.Text = "00:00:00"
'--- ALBUM ---- prima usavo 'Exec ["mp3info", "-p", "%l", filepath] To sOutput
TextBox_album.Text = Mp3_Tag_album
TextArea_Comments.Text = "album: " & Mp3_Tag_album & Chr(10) 'prima era sOutput
'--- NUMERO della TRACCIA --- prima usavo ' Exec ["mp3info", "-p", "%n", filepath] To sOutput
TextBox_Track.Text = Mp3_Tag_traccia
TextArea_Comments.Text = TextArea_Comments.Text & "track # " & Mp3_Tag_traccia & Chr(10) 'prima era sOutput
'--- NOTE varie ---- prima usavo ' Exec ["mp3info", "-p", "%c", filepath] To sOutput
TextArea_Comments.Text = TextArea_Comments.Text & Mp3_Tag_commento 'prima era sOutput
If Mp3_Tag_genere <> "" Then TextArea_TAGS.Text = TextArea_TAGS.Text & Mp3_Tag_genere
Try Player_A.Close
Case "ogg", "flac"
Exec ["ogginfo", filepath] To sOutput
For Each sOutput In Split(sOutput, "\n")
sOutput = Trim(sOutput)
aScan = Scan(sOutput, "*: *m:*s")
If aScan.Count = 3 Then
'Return CInt(CInt(aScan[1]) * 60 + CFloat(Replace(aScan[2], ",", ".")) + 0.5)
Endif
Next
End Select
End