i'm makin a mp3 player.. and i wanted to know how to make the progress bar load according to the time of the selected mp3.. Is it possible.. can u gimme some examples.. thanx in advance
Posted on 2005-08-28 01:03:04 by lone_samurai5
Calculate the total playtime (seconds, miliseconds, frames - you choose).

Create a progress bar control and set max to 1.000.

Calculate currentpos*1000/totallength, and set that as current value.
Posted on 2005-08-28 11:24:52 by f0dder
Could U Pls Give Me An Example...
Posted on 2005-08-28 12:32:40 by lone_samurai5
Set the progess bar max to 1000.

Say you have an MP3 file which consists of (a guess) 16384 frames.


Let us say we are at frame 400, using f0dder's formula:

400 *( 1000 / 16384)  = 24.414

so you would pass 24 to the progress bar control and it will reflect the change.
Posted on 2005-08-28 22:14:34 by x86asm
(400 * 1000) / 16384 would probably be better, if we're working with integers rather than floats :)
Posted on 2005-08-28 22:24:15 by f0dder
I am working on a MP3-Player too and I also want to have a progressbar within my player.
OK I understand the basics of controling a progressbar but after calculating a bit around my progressbar does not do what I want, it did not set a ne position.

But just look at my code:
    invoke CreateWindowEx,0,SADD("msctls_progress32"),0,PBS_SMOOTH or WS_VISIBLE or WS_CHILD,
    mov hProgressBar,eax
    mov eax,1000
    shl eax,16
    invoke SendMessage,hProgressBar,PBM_SETRANGE,0,eax

    invoke MCIWndGetLength,mcihWnd
    mov total,eax
    invoke MCIWndGetPosition,mcihWnd
    mov current,eax
    invoke IntMul,current,100
    invoke IntDiv,eax,total
    invoke IntMul,eax,1000
    invoke IntDiv,eax,100
    invoke SendMessage,hScrollBar,PBM_SETPOS,eax,0

this little calculations should make my progressbar show a reflection off the current position of the track relative to the range of the progressbar (range = 1000)

but when PBM_SETPOS is sent, just nothing happens
so, I think the cause must have something to do with my calculations
please can someone check this

thx in advance, ChigpA

P.S.: Here are my IntMul and IntDiv functions

IntMul PROC source:DWORD,multiplier:DWORD

    LOCAL var1:DWORD

    fild source
    fild multiplier
    fist var1
    mov eax,var1



IntDiv PROC source:DWORD,divider:DWORD

    LOCAL var1:DWORD

    fild source    ; load source
    fild divider    ; load divider
    fdiv            ; divide source by divider
    fist var1      ; store result in variable
    mov eax, var1


Posted on 2005-08-30 07:21:24 by ChigpA
I seem to have the same prob, somethin wrong with my calculations.. Coz my progress bar works but the timing is wrong.. Pls if u have some code.. i'll be really gratefull.. thanx
Posted on 2005-09-01 09:41:12 by lone_samurai5