[Gambas-user] Track playing process bar
Johny Provoost
johny.provoost at ...27...
Thu Aug 5 17:33:23 CEST 2010
I would like to add a progress bar / line to a MP3 player. Is it possible
>> to retrieve the length and the current position of the track with Gambas2
>> ? Thanks!
>>
> Alas, not for MP3. SDL has no way to guess the length of a MP3 file (funny
> format isn't it?). You just have the time position.
>
> Regards,
>
>
I know it's very durty but you can read the tags of the mp3 file. (only
possibility I found within my small knowledge of programming.
You must have exiftool installed. I use Ubuntu and exiftool is not
standard installed.
/'Create tags
PUBLIC FUNCTION FillTags(vFile AS String)
DIM hTags AS File
DIM NoNeedFor AS String
DIM vIndex AS Integer = 0
vIDindex = vIDindex + 1
Start.lblOpstarten.Text = ("Ogenblikje a.u.b. Bezig met aanmaken
muziekdatabase - Record: " & Str$(vIDindex))
WAIT 0.01
'Read Tags
' Put the tags in a textfile. The name and path of the mp3 is in
vFile and write the tags in a txtfile tagstmp.
SHELL "exiftool " & "\"" & vFile & "\"" & " >" & FMain.EigenDir &
"/jepe/SiMuP/tagstmp " WAIT
'Open the file for reading
hTags = OPEN FMain.EigenDir & "/jepe/SiMuP/tagstmp" FOR INPUT
WHILE NOT Eof(hTags)
LINE INPUT #hTags, NoNeedFor '1-Exiftool Version Number
IF Left$(NoNeedFor, 9) = "File Name" THEN
vFilename = Right$(NoNeedFor, Len(NoNeedFor) - RInStr(NoNeedFor,
":") - 1)
ENDIF
IF Left$(NoNeedFor, 9) = "Directory" THEN
vDirectory = Right$(NoNeedFor, Len(NoNeedFor) - RInStr(NoNeedFor,
":") - 1)
ENDIF
IF Left$(NoNeedFor, 27) = "File Modification Date/Time" THEN
vFileModification = Right$(NoNeedFor, Len(NoNeedFor) -
RInStr(NoNeedFor, ": ") - 1)
ENDIF
IF Left$(NoNeedFor, 13) = "Audio Bitrate" THEN
vBitrate = Right$(NoNeedFor, Len(NoNeedFor) - RInStr(NoNeedFor,
":") - 1)
ENDIF
IF Left$(NoNeedFor, 11) = "Sample Rate" THEN
vSampleRate = Right$(NoNeedFor, Len(NoNeedFor) -
RInStr(NoNeedFor, ":") - 1)
ENDIF
IF Left$(NoNeedFor, 12) = "Channel Mode" THEN
vChannelMode = Right$(NoNeedFor, Len(NoNeedFor) -
RInStr(NoNeedFor, ":") - 1)
ENDIF
IF Left$(NoNeedFor, 5) = "Title" THEN
vTitle = Right$(NoNeedFor, Len(NoNeedFor) - RInStr(NoNeedFor,
":") - 1)
ENDIF
IF Left$(NoNeedFor, 6) = "Artist" THEN
vArtist = Right$(NoNeedFor, Len(NoNeedFor) - RInStr(NoNeedFor,
":") - 1)
ENDIF
IF Left$(NoNeedFor, 5) = "Album" THEN
vAlbum = Right$(NoNeedFor, Len(NoNeedFor) - RInStr(NoNeedFor, " :
") - 1)
ENDIF
IF Left$(NoNeedFor, 5) = "Track" THEN
vTrack = Right$(NoNeedFor, Len(NoNeedFor) - RInStr(NoNeedFor,
":") - 1)
ENDIF
IF Left$(NoNeedFor, 5) = "Genre" THEN
vGenre = Right$(NoNeedFor, Len(NoNeedFor) - RInStr(NoNeedFor,
":") - 1)
ENDIF
IF Left$(NoNeedFor, 8) = "Composer" THEN
vComposer = Right$(NoNeedFor, Len(NoNeedFor) - RInStr(NoNeedFor,
":") - 1)
ENDIF
IF Left$(NoNeedFor, 4) = "Year" THEN
vYear = Right$(NoNeedFor, Len(NoNeedFor) - RInStr(NoNeedFor, ":")
- 1)
ENDIF
IF Left$(NoNeedFor, 8) = "Duration" THEN
vDuration = Right$(NoNeedFor, Len(NoNeedFor) - RInStr(NoNeedFor,
": ") - 1)
vDuration = Left$(vDuration, 5)
ENDIF
WEND
CLOSE #hTags/
Greetings Johny
More information about the User
mailing list