MCI correct track length
Posted: Sat Sep 07, 2024 1:45 pm
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
THX
http://www.purebasic.com
https://www.purebasic.fr/english/
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
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