mIRC Home    About    Download    Register    News    Help

Print Thread
Scroll bar. #52742 06/10/03 09:53 AM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Hello, I've wrote an mp3 script, I keep updating it which is one of my major problems, I decided to make a volume scroll bar, my problem is wether I click the < button or the > button in the dialog, the volume still increases, I want to be able to decrease the volume when I click the < button.
Is this possible?
This is what I have:
Code:
on 1:LOAD: {
  set %mp3dir $sdir="Choose your directory"
  mp3list
  dialog -dm mp3player mp3player
}


alias repeat {
  if ($insong == $true) { halt }
  set %mp3 %mp3
  ame 1(12 $+ $remove($nopath(%mp3),.mp3) $+ 1) $+ 1(12 $+ $lengthmp3 $+ 1) $+ 1(12 $+ $round($calc($file(%mp3) / 1000000),2)) $+ mb $+ 1) $+ 1(12 $+ $mp3(%mp3).bitrate $+ kbps $+ / $+ $calc($mp3(%mp3).sample / 1000)) $+ khz $+ 1)1(Repeat Mp31) 
  splay %mp3
}

alias random {
  set %r1 $findfile(%mp3dir,*.mp3,0)
  set %r2 $rand(1,%r1)  
  set %mp3 $findfile(%mp3dir,*.mp3,%r2)  
  ame 1(12 $+ $remove($nopath(%mp3),.mp3) $+ 1) $+ 1(12 $+ $lengthmp3 $+ 1) $+ 1(12 $+ $round($calc($file(%mp3) / 1000000),2)) $+ mb $+ 1) $+ 1(12 $+ $mp3(%mp3).bitrate $+ kbps $+ / $+ $calc($mp3(%mp3).sample / 1000)) $+ khz $+ 1)1(Random Mp31)    
  splay %mp3
}

alias forward {
  if (!$insong) &amp;&amp; (!$dialog(mp3player)) { return }
  else { splay seek $calc($inmp3.pos + (10 * 1000)) }
}

alias back {
  if ($insong == $false) &amp;&amp; ($dialog(mp3player)) { return }
  else { splay seek $calc($inmp3.pos - (10 * 1000)) }
}

alias lengthmp3 {
  set %length $calc($int($calc($mp3(%mp3).length / 1000)) / 60)
  set %mins $int(%length)
  set %secs $calc(%length - %mins)
  set %secs $round($calc(%secs * 60),0)
  if (%mins &lt; 10) { %mins = $+(0,%mins) }
  if (%secs &lt; 10) { %secs = $+(0,%secs) }
  return $+(%mins,:,%secs)
}

alias mp3list {
  %total = $findfile(%mp3dir,*.mp3,0)
  %list = 0
  write -c playlist.txt
  :loop
  inc %list 1
  if (%list &gt; %total) { goto end }
  else { write playlist.txt did -a mp3player 6 $remove($nopath($findfile(%mp3dir,*.mp3,%list)),.mp3)  | goto loop }
  :end
  write -i playlist.txt
  unset %list.*
} 

dialog mp3player {
  title "Slades' mp3 player"
  size -1 -1 158 235
  option dbu
  box "Slades' Mp3 Playlist", 1, 5 5 148 121
  list 6, 7 12 144 111, sort size
  button "Play", 8, 7 135 40 12, ok
  button "Pause", 9, 58 135 41 12, ok
  button "Stop", 10, 111 135 42 12, ok
  button "&gt;", 14, 111 150 42 12, ok
  button "&lt;", 16, 7 150 40 12, ok
  button "Close", 11, 7 214 144 16, ok
  box "Volume control", 17, 7 176 144 32
  radio "Repeat", 13, 58 150 42 12, push
  radio "Random", 15, 58 164 42 12, push
  scroll "",20, 10 190 80 10,top, horizontal, range 16
}

on *:dialog:mp3player:scroll:20: {
  vol -vw $calc($vol(mp3) + 4000)
}

on *:dialog:Mp3Player:init:*: {
  if (%mp3dir != $false) { play -cs playlist.txt 10 | mp3list }
  else { set %mp3dir $null=" Choose Mp3 Directory " | mp3list | .timer 1 1 dialog -x mp3player mp3player | .timer 1 3 dialog -dm mp3player mp3player }
}

on *:dialog:Mp3Player:dclick:6: {
  .set %mp3 %mp3dir $+ $did(6,$did(6).sel) $+ .mp3
  ame 1(12 $+ $remove($nopath(%mp3),.mp3) $+ 1) $+ 1(12 $+ $lengthmp3 $+ 1) $+ 1(12 $+ $round($calc($file(%mp3) / 1000000),2)) $+ mb $+ 1) $+ 1(12 $+ $mp3(%mp3).bitrate $+ kbps $+ / $+ $calc($mp3(%mp3).sample / 1000)) $+ khz $+ 1) 
  splay %mp3
  if ($did(mp3player,13).state == 1) { did -u mp3player 13 }
  if ($did(mp3player,15).state == 1) { did -u mp3player 15 }
}

on *:dialog:Mp3Player:sclick:8: {
  if ($did(6,$did(6).sel) == $null) { Echo -a *** Please choose a song from your playlist then click play. Alternatively you can double click on a song from your playlist. }
  else { 
    .set %mp3 %mp3dir $+ $did(6,$did(6).sel) $+ .mp3
    ame 1(12 $+ $remove($nopath(%mp3),.mp3) $+ 1) $+ 1(12 $+ $lengthmp3 $+ 1) $+ 1(12 $+ $round($calc($file(%mp3) / 1000000),2)) $+ mb $+ 1) $+ 1(12 $+ $mp3(%mp3).bitrate $+ kbps $+ / $+ $calc($mp3(%mp3).sample / 1000)) $+ khz $+ 1) 
    splay %mp3
    if ($did(mp3player,13).state == 1) { did -u mp3player 13 }
    if ($did(mp3player,15).state == 1) { did -u mp3player 15 }
  }
}

on *:dialog:mp3player:sclick:9: {
  if ($did(9) == Pause) { splay pause | did -a mp3player 9 Resume }
  elseif ($did(9) == Resume) { splay resume | did -a mp3player 9 Pause }
}

on *:dialog:mp3player:sclick:10: {
  if ($did(mp3player,13).state == 1) { did -u mp3player 13 }
  if ($did(mp3player,15).state == 1) { did -u mp3player 15 }
  splay stop
}

on *:dialog:mp3player:sclick:15: {
  if ($did(mp3player,15).state == 1) { random }
}

on *:dialog:mp3player:sclick:13: {
  if ($did(mp3player,13).state == 1) { repeat }
}

on *:dialog:mp3player:sclick:14: { forward }
on *:dialog:mp3player:sclick:16: { back }
on *:MP3END: { 
  if ($dialog(mp3player) != $null) &amp;&amp; ($did(mp3player,13).state == 1) { repeat }
  if ($dialog(mp3player) != $null) &amp;&amp; ($did(mp3player,15).state == 1) { random }
}


Now, as I said that will only increase as I don't know how mIRC would know that I am clicking the < button to decrease. Does anyone have a solution What am I missing?

Re: Scroll bar. #52743 06/10/03 10:40 AM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
The size of the script you pasted is kinda intimidating (I was about to pass by your post when I saw the size) but the actually relevant code is just:
Code:
on *:dialog:mp3player:scroll:20: {
  vol -vw $calc($vol(mp3) + 4000)
}
It's not surprising that the volume only increases, since you specifically made it this way: you're adding 4000 to the current volume level whenever you scroll either back or forward. What you should do instead is keep track of the position of the scrollbar, which you can retrieve with $did().sel
Code:
on *:dialog:mp3player:scroll:20: {
  vol -vw $calc($did(20).sel * 4096)
}
65536 is the number of different volume levels and since you have 16 'steps' in your scrollbar, you should inc/dec the volume by 65536/16 = 4096


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: Scroll bar. #52744 06/10/03 10:47 AM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Ahh cheers mate, that's where I went wrong.
Thanks once again. smile

Re: Scroll bar. #52745 06/10/03 11:13 AM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Ok, I have one more question, how would I make it record it's current position then.
I can set it's position by set %vol.pos $did(mp3player,2o).sel when i close the dialog, but the problem is displaying it when i open the dialog, is there a /did command for this?

Re: Scroll bar. #52746 06/10/03 11:25 AM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Yes, you can use /did -c mp3player 20 %vol.pos


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: Scroll bar. #52747 06/10/03 11:36 AM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Ahh of course!
Thanks once again mate. grin