Skip to main content
Topic: 'Seekbar' background for selected track (Read 2073 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

'Seekbar' background for selected track

I have seen a few people with quite a nice feature on their playlists - When a track is selected, there is a seekbar in the background of that selection. I'm assuming that this 'seekbar' isn't actually clickable, but actually just a rectangle drawn with a width depending on the progress of the track. I have tried to do this on mine too, but unfortunately I haven't got it to work, so can somebody help me to debug this code please?...

Here is the code for the item display: (just the default SCPL item display modified for this)

Code: [Select]
$if(%_selected%,$drawrect(0,0,0,0,brushcolor-SYSCOL-13 pencolor-null))
$if(%_selected%,$textcolor(SYSCOL-9),$textcolor(SYSCOL-0))

[color=#FF0000]// PerSecond
$if(%_focused%,
$drawrect(0,0,0,0,brushcolor-SYSCOL-13 pencolor-null)
$drawrect(1,1,$eval(( %playback_time_seconds%/ %length_seconds%)*%_width%),$eval(%_height%-2),brushcolor-0-0-0 pencolor-null)
)[/color]

$drawrect(0,0,%_width%,1,brushcolor-null pencolor-null)

$padding(4,0)
$align(right,top)%title%
$align(left,top)$textcolor(80-80-80)%list_index%

Seems to me that ([time passed]/[total track time] ) * [width] should be reasonable to acheive this, so I'm not sure whats wrong. So how is this actually done then? 

Thanks for any help
-mac

'Seekbar' background for selected track

Reply #1
Credits to Brumal:

Put this in your $if(%isplaying%,... conditional statement.

Code: [Select]
$puts(progress,$muldiv(%playback_time_seconds%,$sub(%_width%,70),%length_seconds%))
    $ifgreater($get(progress),0,
            $drawrect(Xoffset,Yoffset,$get(progress),$sub(%_height%,8),brushcolor-0-0-0 pencolor-0-0-0)
        ,)


The $sub(%_width%,70) defines the length on the rectangle when %_time_remaining% is 0.


EDIT: I just saw your code and it is right and I'm not sure whats wrong. :/
EDIT 2: Err I think you just need to put in %isplaying% rather than %_focused%

'Seekbar' background for selected track

Reply #2
Thanks I tried to put %isplaying% instead but that didn't work.
I replaced my statement with yours, and it works so you were right in the first place  , but the alignment of the rectangle is a bit off - that should be easily fixed though.

Thanks.
-mac

EDIT: Sorted it now^^ just changed x and y offset to 1,1 instead. Looks really good too, I'm going to try it out with some images now instead of rectangles.

'Seekbar' background for selected track

Reply #3
Oh! I think yours didn't work because the the division created a decimal number. $muldiv rounds to the closest integer while the "/", I think, doesn't round it off.

 
SimplePortal 1.0.0 RC1 © 2008-2020