I am looking for function how to get correct MP3 length via MCI, using "Status length" does not return correct value. Can somebody help me?
THX
MCI correct track length
Re: MCI correct track length
Code: Select all
Procedure.l Mci(command.s)
Shared buffer.s
buffer=Space(256)
ProcedureReturn mciSendString_(command,@buffer,256,0)
EndProcedure
file.s="C:\Users\Paul\Desktop\taxman.mp3"
If OpenWindow(0,0,0,400,80,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ProgressBarGadget(1,10,20,380,40,0,100,#PB_ProgressBar_Smooth)
If Mci("open "+Chr(34)+file+Chr(34)+" type MpegVideo alias mp3")=0
Mci("set mp3 time format milliseconds")
Mci("status mp3 length wait")
totallength=Val(buffer)
SetWindowTitle(0,"Total Length: "+totallength+" ms")
Mci("play mp3 from 1")
Repeat
Event=WaitWindowEvent(1)
Mci("status mp3 position")
timeleft=Val(buffer)
played.f=(timeleft/totallength)*100
SetGadgetState(1,played)
Until Event = #PB_Event_CloseWindow
Else
Debug "Failed to open MP3"
EndIf
EndIf
Re: MCI correct track length
Hi Paul, unfortunately no
Try it with this file: https://www.ctvrtky.info/wp-content/upl ... ffects.mp3
Lukas

Lukas
Re: MCI correct track length
Works fine here, reports 32343 ms in length.l1marik wrote: Mon Sep 09, 2024 3:45 pm Hi Paul, unfortunately noTry it with this file: https://www.ctvrtky.info/wp-content/upl ... ffects.mp3
Lukas
Tested on fresh install of Windows 8, 10 & 11 with no special CODEC pack installed.
Re: MCI correct track length
Hi Paul,
a, yes it shows cca 32 seconds
b, reality is cca 16 seconds
Lukas
a, yes it shows cca 32 seconds
b, reality is cca 16 seconds

Lukas
Re: MCI correct track length
I think there is something wrong/odd with that MP3 file.
If I load it that MP3 into VLC, it briefly displays 32 seconds before changing to 16 seconds.
If I resave the file using VLC, the new file displays 16 seconds in VLC and using the MCI commands it now shows 16040ms in length.
If I load it that MP3 into VLC, it briefly displays 32 seconds before changing to 16 seconds.
If I resave the file using VLC, the new file displays 16 seconds in VLC and using the MCI commands it now shows 16040ms in length.