All pastes #1709146 Raw Edit

Something

public text v1 · immutable
#1709146 ·published 2009-12-10 03:31 UTC
rendered paste body
menu * {
  -
  compro-mp3:dialog -rmdie mp3system mp3system
  mp3 playlist:/run notepad.exe mp3-que.txt
  -  
}

dialog mp3system {
  title "compro's MP3 Player"
  size -1 -1 598 240
  option pixels
  box "Mode", 1, 24 8 227 42
  radio "Single", 2, 85 22 50 22, group push
  radio "Random", 3, 138 22 50 22, push
  radio "OnDeck", 4, 191 22 50 22, push
  box "Advertise", 5, 256 8 175 42
  radio "All", 6, 265 22 50 22, group push
  radio "Echo", 7, 318 22 50 22, push
  radio "Selected", 8, 371 22 50 22, push
  button "r.Play", 9, 125 75 40 23
  check "Pause", 10, 166 75 40 23, group push
  button "Stop", 11, 206 75 40 23
  box "Play Control", 12, 77 60 175 42
  box "Directory", 13, 261 60 175 42
  edit "", 14, 270 77 130 20, read autohs
  button "?", 15, 403 77 30 20
  button "s.Play", 16, 84 75 40 23
  box "OnDeck Control", 17, 76 113 175 42
  box "Currently OnDeck", 18, 260 113 175 42
  edit "", 19, 269 129 160 20, read autohs
  button "Select", 20, 138 127 50 22
  button "Play", 21, 85 127 50 22
  button "Random", 22, 191 127 50 22
  box "Currently Playing", 23, 74 168 360 65
  check "", 25, 351 195 70 23, group push
  edit "", 26, 83 185 252 20, read autohs
  edit "", 27, 83 208 57 20, read autohs
  edit "", 28, 148 208 57 20, read autohs
  edit "", 29, 213 208 57 20, read autohs
  edit "", 24, 278 208 57 20, read autohs
  box "Channel Control", 30, 442 7 150 227
  combo 31, 450 26 135 160, sort hsbar
  button "Add", 32, 449 183 68 20
  button "Delete", 33, 518 183 68 20
  check "Advertise", 34, 449 209 137 20, group push
  radio "Play Dir", 35, 32 22 50 22, group push
}

alias updatemp3 {
  if ($dialog(mp3system) == mp3system) {
    if ($1 == playing) { did -u mp3system 10 | ump3pi }
    if ($1 == ondeck) {
      if ($mp3read(mp3vars,r,mp3,play) == ondeck) { 
        if ($mp3read(mp3vars,r,mp3,ondeck) == $null) {
          var %ondeck = $findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,$rand(1,$findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,0)))
          if ((%ondeck == 0) || (%ondeck == $null)) { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ There are no mp3s in $mp3read(mp3vars,r,mp3,dir) to put ondeck. $+ $lr(r) | did -r mp3system 19 | return }
          $mp3read(mp3vars,w,mp3,ondeck,%ondeck)
        }
        did -r mp3system 19 | did -a mp3system 19 $left($nopath($mp3read(mp3vars,r,mp3,ondeck)),-4)
      }
    }
    if ($1 == stop) { did -b mp3system 25 | did -u mp3system 10 | did -r mp3system 24,26,27,28,29 }
    if ($1 == pause) { did -c mp3system 10 }
    if ($1 == unpause) { did -u mp3system 10 }
    if ($1 == repeat) { did -c mp3system 25 | did -r mp3system 25 | did -a mp3system 25 Repeat: On }
    if ($1 == unrepeat) { did -u mp3system 25 | did -r mp3system 25 | did -a mp3system 25 Repeat: Off }
    if ($1 == channels) {
      var %i = $mp3read(mp3vars,r,mp3advertise,0)
      while (%i) {
        did -a mp3system 31 $mp3read(mp3vars,r,mp3advertise,%i)
        dec %i
      }
    }
    if ($1 == channelbuttons) {
      var %text = $replace($did(mp3system,31,0).text,$chr(32),)
      if (%text == $null) { did -b mp3system 32,33,34 | did -u mp3system 34 | return }
      if ($didwm(mp3system,31,%text) == 0) { did -e mp3system 32 | did -b mp3system 33,34 | did -u mp3system 34 | return }
      if ($didwm(mp3system,31,%text) != 0) { 
        did -e mp3system 33,34 | did -b mp3system 32
        var %tf = $mp3read(mp3vars,r,mp3advertise,%text)
        if (%tf == true) { did -r mp3system 34 | did -c mp3system 34 | did -a mp3system 34 Advertise }
        if (%tf == false) { did -r mp3system 34 | did -u mp3system 34 | did -a mp3system 34 Don't Advertise }
        return
      }
    }
  }
}
alias ump3pi {
  did -e mp3system 25
  did -r mp3system 24,26,27,28,29
  did -a mp3system 26 $left($nopath($inmp3.fname),-4)
  did -a mp3system 27 $duration2nc($calc($mp3($inmp3.fname).length /1000))
  did -a mp3system 28 $mp3($inmp3.fname).bitrate $+ kbps
  did -a mp3system 29 $calc($mp3($inmp3.fname).sample /1000) $+ kHz
  did -a mp3system 24 $round($iif($file($inmp3.fname).size > 1048576,$calc($file($inmp3.fname).size / 1048576),$calc($file($inmp3.fname).size / 1024)),2) $+ $iif($file($inmp3.fname).size > 1048576,mb,kb)
}
on *:dialog:mp3system:*:* {
  if ($devent == init) {
    mp3varset
    did -b mp3system 25,32,33,34
    if ($mp3read(mp3vars,r,mp3,play) == single) { did -c mp3system 2 | did -b mp3system 17,18,19,20,21,22 }
    if ($mp3read(mp3vars,r,mp3,play) == random) { did -c mp3system 3 | did -b mp3system 17,18,19,20,21,22 }
    if ($mp3read(mp3vars,r,mp3,play) == playalldir) { did -c mp3system 35 | did -b mp3system 17,18,19,20,21,22 }
    if ($mp3read(mp3vars,r,mp3,play) == ondeck) { did -c mp3system 4 | updatemp3 ondeck }
    if ($mp3read(mp3vars,r,mp3,advertise) == all) { did -c mp3system 6 }
    if ($mp3read(mp3vars,r,mp3,advertise) == echo) { did -c mp3system 7 }
    if ($mp3read(mp3vars,r,mp3,advertise) == selected) { did -c mp3system 8 }
    if ($mp3read(mp3vars,r,mp3,paused) == true) { did -c mp3system 10 }
    did -a mp3system 14 $mp3read(mp3vars,r,mp3,dir)
    if ($inmp3.fname != $null) {
      ump3pi
      if ($inmp3.fname == $mp3read(mp3vars,r,mp3,repeat)) { updatemp3 repeat }
      if ($inmp3.fname != $mp3read(mp3vars,r,mp3,repeat)) { updatemp3 unrepeat }
    }
    if ($inmp3.fname == $null) { $mp3read(mp3vars,d,mp3,repeat) | updatemp3 unrepeat }
    updatemp3 channels
  }
  if ($devent == mouse) {
    if ($did == 30) {
      if ($replace($did(mp3system,31,0).text,$chr(32),) == $null) { did -b mp3system 32,33,34 | did -u mp3system 34 }
    }
  }
  if ($devent == edit) {
    if ($did == 31) { updatemp3 channelbuttons }
  }
  if ($devent == sclick) {
    if ($did == 2) { $mp3read(mp3vars,w,mp3,play,single) | did -b mp3system 17,18,19,20,21,22 | did -r mp3system 19 }
    if ($did == 3) { $mp3read(mp3vars,w,mp3,play,random) | did -b mp3system 17,18,19,20,21,22 | did -r mp3system 19 }
    if ($did == 4) { $mp3read(mp3vars,w,mp3,play,ondeck) | $mp3read(mp3vars,d,mp3,ondeck) | did -e mp3system 17,18,19,20,21,22 | updatemp3 ondeck }
    if ($did == 35) { $mp3read(mp3vars,w,mp3,play,playalldir) | did -b mp3system 17,18,19,20,21,22 | did -r mp3system 19 | playalldir }
    if ($did == 6) { $mp3read(mp3vars,w,mp3,advertise,all) }
    if ($did == 7) { $mp3read(mp3vars,w,mp3,advertise,echo) }
    if ($did == 8) { $mp3read(mp3vars,w,mp3,advertise,selected) }
    if ($did == 9) { mp3randomsong }
    if ($did == 10) { 
      if ($inmp3.fname == $null) { did -u mp3system 10 | return }
      if ($mp3read(mp3vars,r,mp3,paused) == true) { mp3resume | return }
      if ($mp3read(mp3vars,r,mp3,paused) == $null) { mp3pause | return }
    }
    if ($did == 11) { mp3stop }
    if ($did == 15) {
      var %dir = $sdir($iif($mp3read(mp3vars,r,mp3,dir) != $null,$mp3read(mp3vars,r,mp3,dir),$mircdir),Select Your mp3 Directory)
      if (%dir != $null) { $mp3read(mp3vars,d,mp3,ondeck) | $mp3read(mp3vars,w,mp3,dir,%dir) | did -r mp3system 14 | did -a mp3system 14 $mp3read(mp3vars,r,mp3,dir) | updatemp3 ondeck }
    }
    if ($did == 16) { mp3selectsong }
    if ($did == 20) { mp3changeondeck }
    if ($did == 21) { mp3playondeck }
    if ($did == 22) { mp3randomondeck }
    if ($did == 25) {
      if ($mp3read(mp3vars,r,mp3,repeat) == $null) { $mp3read(mp3vars,w,mp3,repeat,$inmp3.fname) | updatemp3 repeat | return }
      if ($mp3read(mp3vars,r,mp3,repeat) != $null) { $mp3read(mp3vars,d,mp3,repeat) | updatemp3 unrepeat | return }
    }
    if ($did == 31) { updatemp3 channelbuttons }
    if ($did == 32) {
      var %text = $replace($did(mp3system,31,0).text,$chr(32),)
      if (%text == $null) { updatemp3 channelbuttons | return }
      $mp3read(mp3vars,w,mp3advertise,%text,true)
      did -a mp3system 31 %text
      did -d mp3system 31 0
      updatemp3 channelbuttons
    }
    if ($did == 33) {
      var %text = $replace($did(mp3system,31,0).text,$chr(32),)
      if (%text == $null) { updatemp3 channelbuttons | return }
      $mp3read(mp3vars,d,mp3advertise,%text)
      did -d mp3system 31 $didwm(mp3system,31,%text)
      did -u mp3system 31
      updatemp3 channelbuttons
    }
    if ($did == 34) {
      var %text = $replace($did(mp3system,31,0).text,$chr(32),)
      if (%text == $null) { updatemp3 channelbuttons | return }
      if ($mp3read(mp3vars,r,mp3advertise,%text) == true) { $mp3read(mp3vars,w,mp3advertise,%text,false) | updatemp3 channelbuttons | return }
      if ($mp3read(mp3vars,r,mp3advertise,%text) == false) { $mp3read(mp3vars,w,mp3advertise,%text,true) | updatemp3 channelbuttons | return }
    }
  }
}


alias mp3display { return $chr(3) $+ 6 $+ * $me is now listening to $nopath($inmp3.fname) [ $+ $duration2($calc($mp3($inmp3.fname).length /1000)) $+ ][ $+ $mp3($inmp3.fname).bitrate $+ kbps $+ ][ $+ $calc($mp3($inmp3.fname).sample /1000) $+ kHz $+ ][ $+ $round($iif($file($inmp3.fname).size > 1048576,$calc($file($inmp3.fname).size / 1048576),$calc($file($inmp3.fname).size / 1024)),2) $+ $iif($file($inmp3.fname).size > 1048576,mb) $+ $chr(93) }
alias mp3ad { describe $active is now listening to $nopath($inmp3.fname) [ $+ $duration2($calc($mp3($inmp3.fname).length /1000)) $+ ][ $+ $mp3($inmp3.fname).bitrate $+ kbps $+ ][ $+ $calc($mp3($inmp3.fname).sample /1000) $+ kHz $+ ][ $+ $round($iif($file($inmp3.fname).size > 1048576,$calc($file($inmp3.fname).size / 1048576),$calc($file($inmp3.fname).size / 1024)),2) $+ $iif($file($inmp3.fname).size > 1048576,mb) $+ $chr(93) }
alias mp3display222 { return $lr(l) $+ $c(1) $+ mp3 $+ $c(2) $+ $d $+ $c(3) $+ $left($nopath($inmp3.fname),-4) $+ $c(2) $+ $d $+ $c(3) $+ $duration2($calc($mp3($inmp3.fname).length /1000)) $+ $c(2) $+ $d $+ $c(3) $+ $mp3($inmp3.fname).bitrate $+ $c(1) $+ kbps $+ $c(2) $+ $d $+ $c(3) $+ $calc($mp3($inmp3.fname).sample /1000) $+ $c(1) $+ kHz $+ $c(2) $+ $d $+ $c(3) $+ $round($iif($file($inmp3.fname).size > 1048576,$calc($file($inmp3.fname).size / 1048576),$calc($file($inmp3.fname).size / 1024)),2) $+ $iif($file($inmp3.fname).size > 1048576,$c(1) $+ mb $+ $c(3),$c(1) $+ kb $+ $c(3)) $+ $lr(r) }
alias display.select.only {
  var %dso = $ini(mp3vars.ini,mp3advertise,0)
  while (%dso) {
    describe $ini(mp3vars.ini,mp3advertise,%dso) is now listening to $nopath($inmp3.fname) [ $+ $duration2($calc($mp3($inmp3.fname).length /1000)) $+ ][ $+ $mp3($inmp3.fname).bitrate $+ kbps $+ ][ $+ $calc($mp3($inmp3.fname).sample /1000) $+ kHz $+ ][ $+ $round($iif($file($inmp3.fname).size > 1048576,$calc($file($inmp3.fname).size / 1048576),$calc($file($inmp3.fname).size / 1024)),2) $+ $iif($file($inmp3.fname).size > 1048576,mb) $+ $chr(93)
    dec %dso
  }
}

alias mp3randomsong { 
  var %song = $findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,$rand(1,$findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,0)))
  if ((%song == 0) || (%song == $null)) { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ There are no mp3s in $mp3read(mp3vars,r,mp3,dir) to randomly play. $+ $lr(r) | return }
  $mp3read(mp3vars,d,mp3,repeat) | $mp3read(mp3vars,d,mp3,paused) | splay %song | $mp3read(mp3vars,w,mp3,ondeck,$findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,$rand(1,$findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,0)))) | updatemp3 playing | updatemp3 ondeck | updatemp3 unrepeat | $iif($mp3read(mp3vars,r,mp3,play) == ondeck,mp3showondeck) 
}
alias mp3repeat { 
  if ($inmp3.fname == $null) { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ No mp3 is playing. $+ $lr(r) | return }
  else { $mp3read(mp3vars,w,mp3,repeat,$inmp3.fname) | updatemp3 repeat }
}
alias mp3norepeat { 
  if ($mp3read(mp3vars,r,mp3,repeat) == $null) { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ No repeat information exists. $+ $lr(r) | return }
  else { $mp3read(mp3vars,d,mp3,repeat) | updatemp3 unrepeat }
}
alias mp3selectsong { 
  var %song = $sfile($mp3read(mp3vars,r,mp3,dir),Select the mp3)
  if (%song != $null) { splay %song | $mp3read(mp3vars,d,mp3,paused) | $mp3read(mp3vars,d,mp3,repeat) | updatemp3 playing | updatemp3 ondeck | updatemp3 unrepeat | $iif($mp3read(mp3vars,r,mp3,play) == ondeck,mp3showondeck) }
}
alias mp3stop { 
  if ($inmp3.fname == $null) { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ No mp3 is playing. $+ $lr(r) | return }
  else { $mp3read(mp3vars,d,mp3,paused) | $mp3read(mp3vars,d,mp3,repeat) | splay stop | updatemp3 stop | updatemp3 unrepeat }
}
alias mp3pause { 
  if ($inmp3.fname == $null) { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ No mp3 is playing. $+ $lr(r) | return }
  else { $mp3read(mp3vars,w,mp3,paused,true) | splay pause | updatemp3 pause }
}
alias mp3resume {   
  if ($inmp3.fname == $null) { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ No mp3 is playing. $+ $lr(r) | return }
  else { $mp3read(mp3vars,d,mp3,paused) | splay resume | updatemp3 unpause }
}
alias mp3showondeck { 
  if ($dialog(mp3system) == mp3system) { return }
  if ($mp3read(mp3vars,r,mp3,play) != ondeck) { echo -a $lr(l) $+ $c(1) $+ mp3-ondeck $+ $c(2) $+ $d $+ $c(3) $+ ondeck mode is off. $+ $lr(r) | return }
  if ($mp3read(mp3vars,r,mp3,ondeck) == $null) { $mp3read(mp3vars,w,mp3,ondeck,$findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,$rand(1,$findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,0)))) }
  echo -a $lr(l) $+ $c(1) $+ mp3-ondeck $+ $c(2) $+ $d $+ $c(3) $+ $left($nopath($mp3read(mp3vars,r,mp3,ondeck)),-4) $+ $lr(r)
}
alias mp3changeondeck { 
  if ($mp3read(mp3vars,r,mp3,play) != ondeck) { echo -a $lr(l) $+ $c(1) $+ mp3-ondeck $+ $c(2) $+ $d $+ $c(3) $+ ondeck mode is off. $+ $lr(r) | return }
  var %ondeck = $sfile($mp3read(mp3vars,r,mp3,dir),Select the mp3)
  if (%ondeck != $null) { $mp3read(mp3vars,w,mp3,ondeck,%ondeck) | mp3showondeck | updatemp3 ondeck }
}
alias mp3randomondeck {
  if ($mp3read(mp3vars,r,mp3,play) != ondeck) { echo -a $lr(l) $+ $c(1) $+ mp3-ondeck $+ $c(2) $+ $d $+ $c(3) $+ ondeck mode is off. $+ $lr(r) | return }
  else {
    var %ondeck = $findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,$rand(1,$findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,0)))
    if ((%ondeck == 0) || (%ondeck == $null)) { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ There are no mp3s in $mp3read(mp3vars,r,mp3,dir) to put ondeck. $+ $lr(r) | return }
    $mp3read(mp3vars,w,mp3,ondeck,%ondeck)
    updatemp3 ondeck | mp3showondeck 
  }
}
alias mp3playondeck { 
  if ($mp3read(mp3vars,r,mp3,play) != ondeck) { echo -a $lr(l) $+ $c(1) $+ mp3-ondeck $+ $c(2) $+ $d $+ $c(3) $+ ondeck mode is off. $+ $lr(r) | return }
  else { 
    if ($mp3read(mp3vars,r,mp3,ondeck) == $null) {
      var %ondeck = $findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,$rand(1,$findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,0)))
      if ((%ondeck == 0) || (%ondeck == $null)) { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ There are no mp3s in $mp3read(mp3vars,r,mp3,dir) to put ondeck. $+ $lr(r) | return }
      $mp3read(mp3vars,w,mp3,ondeck,%ondeck)
    }
  var %song = $mp3read(mp3vars,r,mp3,ondeck) | $mp3read(mp3vars,w,mp3,ondeck,$findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,$rand(1,$findfile($mp3read(mp3vars,r,mp3,dir),*.mp3,0)))) | $mp3read(mp3vars,d,mp3,paused) | $mp3read(mp3vars,d,mp3,repeat) | splay %song | updatemp3 playing | updatemp3 unrepeat | updatemp3 ondeck | mp3showondeck }
}

on *:mp3end: {
  if ($mp3read(mp3vars,r,mp3,repeat) != $null) { var %file = $mp3read(mp3vars,r,mp3,repeat) | $mp3read(mp3vars,d,mp3,repeat) | $mp3read(mp3vars,d,mp3,paused) | updatemp3 unrepeat | splay %file | return }
  if ($mp3read(mp3vars,r,mp3,play) == single) { return }
  if ($mp3read(mp3vars,r,mp3,play) == random) { mp3randomsong | return }
  if ($mp3read(mp3vars,r,mp3,play) == ondeck) { mp3playondeck | return }
  if ($mp3read(mp3vars,r,mp3,play) == playalldir) { mp3playalldir | return }
  else { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(1) $+ Your mp3 play mode needs to be set to:  $c(3) $+ Single $+ $c(1) $+ $chr(44) $c(3) $+ Random $+ $c(1) $+ $chr(44) or $c(3) $+ OnDeck $+ $c(1) $+ . $+ $lr(r) }
}

alias splay { .splay $1- | $advertise($1-) }

alias advertise { 
  if ($inmp3.fname == $1) { 
    if ($mp3read(mp3vars,r,mp3,advertise) == echo) { echo -a $mp3display | return }
    if (($mp3read(mp3vars,r,mp3,advertise) == selected) && ($mp3read(mp3vars,r,mp3advertise,0) == 0)) { echo -a $mp3display | return }
    if (($mp3read(mp3vars,r,mp3,advertise) == selected) && ($mp3read(mp3vars,r,mp3advertise,0) != 0)) {
      var %i = $mp3read(mp3vars,r,mp3advertise,0)
      while (%i) {
        if ($mp3read(mp3vars,r,mp3advertise,$mp3read(mp3vars,r,mp3advertise,%i)) == True) { var %list = %list $mp3read(mp3vars,r,mp3advertise,%i) }
        dec %i
      }
      ;msg $replace(%list,$chr(32),$chr(44)) $mp3display
      if (%list != $null) { display.select.only | return }
      if (%list == $null) { echo -a $mp3display | return }
    }
    if ($mp3read(mp3vars,r,mp3,advertise) == all) {
      var %i = $mp3read(mp3vars,r,mp3advertise,0)
      while (%i) {
        if ($mp3read(mp3vars,r,mp3advertise,$mp3read(mp3vars,r,mp3advertise,%i)) == False) { var %list = %list $mp3read(mp3vars,r,mp3advertise,%i) }
        dec %i
      }
      var %i = $chan(0)
      while (%i) {
        var %chanlist = %chanlist $chan(%i)
        dec %i
      }
      var %i = $numtok(%list,32)
      while (%i) {
        var %chanlist = $remtok(%chanlist,$gettok(%list,%i,32),32)
        dec %i
      }
      if (%chanlist != $null) { ame is now listening to $nopath($inmp3.fname) [ $+ $duration2($calc($mp3($inmp3.fname).length /1000)) $+ ][ $+ $mp3($inmp3.fname).bitrate $+ kbps $+ ][ $+ $calc($mp3($inmp3.fname).sample /1000) $+ kHz $+ ][ $+ $round($iif($file($inmp3.fname).size > 1048576,$calc($file($inmp3.fname).size / 1048576),$calc($file($inmp3.fname).size / 1024)),2) $+ $iif($file($inmp3.fname).size > 1048576,mb) $+ $chr(93) | return }
      if (%chanlist == $null) { echo -a $mp3display | return }
    }
  }
}

alias mp3varset {
  if ($mp3read(mp3vars,r,mp3,play) == $null) { $mp3read(mp3vars,w,mp3,play,Random) }
  if ($mp3read(mp3vars,r,mp3,advertise) == $null) { $mp3read(mp3vars,w,mp3,advertise,Echo) }
  if ($mp3read(mp3vars,r,mp3,dir) == $null) { 
    var %dir = $sdir($iif($mp3read(mp3vars,r,mp3,dir) != $null,$mp3read(mp3vars,r,mp3,dir),$mircdir),Select Your mp3 Directory)
    if (%dir != $null) { $mp3read(mp3vars,w,mp3,dir,%dir) }
    if (%dir == $null) { $mp3read(mp3vars,w,mp3,dir,$mircdir) }
  }
}

alias c { var %Color = Color $+ $1 | return $chr(3) $+ $mp3read(mp3vars,r,main,%color) }
alias d { return $chr(2) $+ $mp3read(mp3vars,r,main,divider) $+ $chr(2) }
alias lr { if ($1 == l) { return $c(2) $+ $chr(2) $+ [ $+ $chr(2) } | if ($1 == r) { return $c(2) $+ $chr(2) $+ ] $+ $chr(2) $+ $chr(3) } }
alias duration2 { return $remove($replace($duration($int($1)),secs,s,sec,s,mins,m,min,m,hrs,h,hr,h,days,d,day,d,wks,w,wk,w),$chr(32)) }
alias duration2-disabled { return $remove($replace($duration($int($1)),secs,$c(1) $+ s $+ $c(3),sec,$c(1) $+ s $+ $c(3),mins,$c(1) $+ m $+ $c(3),min,$c(1) $+ m $+ $c(3),hrs,$c(1) $+ h $+ $c(3),hr,$c(1) $+ h $+ $c(3),days,$c(1) $+ d $+ $c(3),day,$c(1) $+ d $+ $c(3),wks,$c(1) $+ w $+ $c(3),wk,$c(1) $+ w $+ $c(3)),$chr(32)) }
alias duration2nc { return $remove($replace($duration($int($1)),secs,s,sec,s,mins,m,min,m,hrs,h,hr,h,days,d,day,d,wks,w,wk,w),$chr(32)) }

alias mp3read {
  var %file = $1 $+ .ini
  if ($2 == w) { writeini %file $3 $4 $5- }
  if ($2 == d) {
    if ($3 == $null) { .remove %file }
    if (($4 == $null) && ($3 != $Null)) { remini %file $3 }
    if ($4 != $Null) { remini %file $3 $4 }
  }
  if ($2 == r) {
    if ($4 isnum) { return $ini(%file,$3,$4) }
    if ($3 isnum) { return $ini(%file,$3) }
    else { return $readini -n %file $3 $4 }
  }
}

alias cF6 { dialog -rm systeminfo systeminfo }
alias F7 {
  if ($dialog(mp3system) == mp3system) { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ mp3 Options dialog already open! $+ $lr(r) }
  else { dialog -rmdie mp3system mp3system }
}
alias F8 { mp3varset | mp3repeat }
alias sF8 { mp3varset | mp3norepeat }
alias F9 { mp3varset | mp3randomsong } 
alias sF9 { mp3varset | mp3selectsong }
alias F10 { mp3varset | mp3stop }
alias sF10 { mp3varset | mp3pause }
alias cF10 { mp3varset | mp3resume }
alias F11 { mp3varset | mp3showondeck }
alias sF11 { mp3varset | mp3changeondeck }
alias cF11 { mp3varset | mp3randomondeck }
alias F12 { mp3varset | mp3playondeck }

alias sF1 {
  echo -a $c(4) $+ -
  echo -a $lr(l) $+ $c(1) $+ F1 $+ $c(2) $+ $d $+ $c(3) $+ mIRC help file. $+ $lr(r) 
  echo -a $lr(l) $+ $c(1) $+ shift+F1 $+ $c(2) $+ $d $+ $c(3) $+ Shows this information. $+ $lr(r)
  echo -a $lr(l) $+ $c(1) $+ F7 $+ $c(2) $+ $d $+ $c(3) $+ Opens mp3 player $+ $lr(r)
  echo -a $lr(l) $+ $c(1) $+ F8 $+ $c(2) $+ $d $+ $c(3) $+ Repeat currently playing mp3. $+ $lr(r)
  echo -a $lr(l) $+ $c(1) $+ shift+F8 $+ $c(2) $+ $d $+ $c(3) $+ Delete the mp3 to be repeated. $+ $lr(r)
  echo -a $lr(l) $+ $c(1) $+ F9 $+ $c(2) $+ $d $+ $c(3) $+ Random mp3. $+ $lr(r)
  echo -a $lr(l) $+ $c(1) $+ shift+F9 $+ $c(2) $+ $d $+ $c(3) $+ Select mp3 to play. $+ $lr(r)
  echo -a $lr(l) $+ $c(1) $+ F10 $+ $c(2) $+ $d $+ $c(3) $+ Stop mp3. $+ $lr(r)
  echo -a $lr(l) $+ $c(1) $+ shift+F10 $+ $c(2) $+ $d $+ $c(3) $+ Pause mp3. $+ $lr(r)
  echo -a $lr(l) $+ $c(1) $+ control+F10 $+ $c(2) $+ $d $+ $c(3) $+ Resume mp3. $+ $lr(r)
  echo -a $lr(l) $+ $c(1) $+ F11 $+ $c(2) $+ $d $+ $c(3) $+ Show ondeck mp3. $+ $lr(r)
  echo -a $lr(l) $+ $c(1) $+ shift+F11 $+ $c(2) $+ $d $+ $c(3) $+ Change ondeck mp3. $+ $lr(r)
  echo -a $lr(l) $+ $c(1) $+ control+F11 $+ $c(2) $+ $d $+ $c(3) $+ Random ondeck mp3. $+ $lr(r)
  echo -a $lr(l) $+ $c(1) $+ F12 $+ $c(2) $+ $d $+ $c(3) $+ Play ondeck mp3 now. $+ $lr(r)
  echo -a $c(4) $+ -
}

alias playalldir {
  if ($mp3read(mp3vars,r,mp3,dir) == $null) { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ mp3 directory is missing! $+ $lr(r) | return }
  var %playall = $sdir($mp3read(mp3vars,r,mp3,dir),select a directory that you wish to listen to)
  if (%playall == $null) { return }
  else {
    var %playallmp3s = $findfile($shortfn(%playall),*.mp3,0)
    write -c mp3-que.txt
    while (%playallmp3s) {
      write mp3-que.txt $findfile($shortfn(%playall),*.mp3,%playallmp3s)
      dec %playallmp3s
    }
    if ($lines(mp3-que.txt) > 0) { writeini mp3vars.ini mp3 play playalldir | $mp3read(mp3vars,d,mp3,repeat) | $mp3read(mp3vars,d,mp3,paused) | splay $read(mp3-que.txt,1) | updatemp3 playing | updatemp3 unrepeat | write -dl 1 mp3-que.txt | ump3pi | return }
    else { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ No mp3s was found in; %playall $+ $lr(r) | return }
  }
}

alias mp3playalldir { 
  if ($lines(mp3-que.txt) > 0) { $mp3read(mp3vars,d,mp3,repeat) | $mp3read(mp3vars,d,mp3,paused) | splay $read(mp3-que.txt,1) | updatemp3 playing | updatemp3 unrepeat | write -dl 1 mp3-que.txt | ump3pi | return }
  else { echo -a $lr(l) $+ $c(4) $+ Error $+ $c(2) $+ $d $+ $c(3) $+ No mp3s que'd to play $+ $lr(r) | return }
}