dialog set {
  title "Mp3 Player Setup Utility"
  size -1 -1 400 200
  option pixels
  text "Advertise:", 01, 10 10 50 20
  radio "All Channels", 02, 10 25 80 20, group
  radio "Selected Channels", 03, 10 45 120 20
  radio "No Advertise", 04, 10 65 100 20
  text "Channel Ad List:", 05, 150 10 100 20
  edit "", 06, 150 25 100 20, autohs
  list 07, 150 40 100 100
  button "Add", 08, 150 125 50 20
  button "Clear", 09, 200 125 50 20
  text "Play type:", 10, 270 10 100 20
  radio "Single Play", 11, 270 25 80 20, group
  radio "Continous", 12, 270 45 100 20
  radio "Random Play", 13, 270 65 100 20
  button "Save Setting", 14, 10 160 380 20
}
on *:dialog:set:init:0: {
  oh.man.i.am.so.tired.right.now.its.4.11.am.and.im.still.dooing.this.after.42.hours.straight
}
on *:dialog:set:sclick:13: { set %type.mp3 rand | halt }
on *:dialog:set:sclick:12: { set %type.mp3 cont | halt }
on *:dialog:set:sclick:11: { set %type.mp3 no | halt }
on *:dialog:set:sclick:14: { setupshit }
on *:dialog:set:sclick:02: { set %mp3.advertise all }
on *:dialog:set:sclick:03: { set %mp3.advertise sel }
on *:dialog:set:sclick:04: { set %mp3.advertise none }
on *:dialog:set:sclick:08: { addchannels }
on *:dialog:set:sclick:09: { delchannels }
dialog mp3 {
  title "Crystalline Mp3 Player v1.0"
  size -1 -1 340 500
  option pixels
  icon 01, 15 15 50 20, $mircdirimg\buttn.bmp, noborder
  text "", 02, 80 20 200 14, center, read
  text "", 30, 295 20 27 14, center, read
  icon 04, 15 45 50 20, $mircdirimg\buttn.bmp, noborder
  icon 28, 146 312 50 20, $mircdirimg\buttn.bmp, noborder
  icon 05, 67 45 50 20, $mircdirimg\buttn.bmp, noborder
  icon 06, 119 45 50 20, $mircdirimg\buttn.bmp, noborder
  icon 07, 171 45 50 20, $mircdirimg\buttn.bmp, noborder
  icon 08, 223 45 50 20, $mircdirimg\buttn.bmp, noborder
  icon 09, 275 45 50 20, $mircdirimg\buttn.bmp, noborder
  list 10, 15 70 311 250, sort
  icon 11, 17 312 50 20, $mircdirimg\buttn.bmp, noborder
  icon 12, 71 312 50 20, $mircdirimg\buttn.bmp, noborder
  icon 13, 275 312 50 20, $mircdirimg\buttn.bmp, noborder
  icon 14, 221 312 50 20, $mircdirimg\buttn.bmp, noborder
  text "", 16, 65 347 250 14, center, read
  text "", 18, 62 367 98 13, center, read
  text "", 20, 221 367 98 13, center, read
  text "", 22, 62 387 98 13, center, read
  text "", 24, 221 387 98 13, center, read
  icon 900, 1 1 340 500, $mircdirimg\background.bmp

}
on *:dialog:mp3:sclick:28: { dialog -md set set }
on *:dialog:mp3:sclick:05: { splay stop }
on *:dialog:mp3:sclick:06: { splay pause }
on *:dialog:mp3:sclick:08: { mp3fwd }
on *:dialog:mp3:sclick:07: { mp3back }
on *:dialog:mp3:sclick:09: { splay resume }
on *:dialog:mp3:sclick:01: { gomp3 }
on *:dialog:mp3:sclick:12: { delmp3file }
on *:dialog:mp3:sclick:11: { addmp3file }
on *:dialog:mp3:sclick:14: { redolist }
on *:dialog:mp3:sclick:13: { did -r mp3 10 }
on *:dialog:mp3:sclick:04: { set %cur.file.mp3 $did(mp3,10).seltext | playmp3 }
on *:dialog:mp3:dclick:10: { set %cur.file.mp3 $did(mp3,10).seltext | playmp3 }
on *:mp3end: {
  if (%type.mp3 == cont) { domp3cont }
  if (%type.mp3 == rand) { domp3rand }
  if (%type.mp3 == no) { halt }
}
alias brackets {
  if ($1 == o) { return 4[ | halt }
  if ($1 == c) { return 4] | halt }
}
alias words { 
  if ($1 == main) { return 12 | halt }
  if ($1 == secondary) { return 11 | halt }
}
alias playmp3 {
  splay $findfile(%mp3.dir,%cur.file.mp3,1)
  did -r mp3 16
  did -r mp3 18
  did -r mp3 22
  did -r mp3 20
  did -r mp3 24  
  did -a mp3 16 %cur.file.mp3
  did -a mp3 18 $duration($calc($sound($findfile(%mp3.dir,%cur.file.mp3,1)).length / 1000))
  did -a mp3 22 $sound($findfile(%mp3.dir,%cur.file.mp3,1)).sample $+ Khz
  did -a mp3 20 $sound($findfile(%mp3.dir,%cur.file.mp3,1)).bitrate $+ Kbps
  did -a mp3 24 $bytes($file($findfile(%mp3.dir,%cur.file.mp3,1)).size).suf
  mp3add
}
alias mp3add { 
  if (%mp3.advertise == all) { amsg 12-[15Mp3 12-15 %cur.file.mp3 $+ 12]- -[15 $+ $duration($calc($sound($findfile(%mp3.dir,%cur.file.mp3,1)).length / 1000)) $+ 12/15 $+ $sound($findfile(%mp3.dir,%cur.file.mp3,1)).bitrate $+ Kbps12]- | halt }
  if (%mp3.advertise == sel) { msg %selchans.mp3.ad 12-[15Mp3 12-15 %cur.file.mp3 $+ 12]- -[15 $+ $duration($calc($sound($findfile(%mp3.dir,%cur.file.mp3,1)).length / 1000)) $+ 12/15 $+ $sound($findfile(%mp3.dir,%cur.file.mp3,1)).bitrate $+ Kbps12]- | halt }
  if (%mp3.advertise == none) { echo -s 12-[15Mp3 12-15 %cur.file.mp3 $+ 12]- -[15 $+ $duration($calc($sound($findfile(%mp3.dir,%cur.file.mp3,1)).length / 1000)) $+ 12/15 $+ $sound($findfile(%mp3.dir,%cur.file.mp3,1)).bitrate $+ Kbps12]- | halt }
}
alias gomp3 {
  set %mp3.dir $sdir($mircdir,Select mp3 Directory Please.)
  if (%mp3.dir == $null) { halt }
  did -r mp3 02  
  did -r mp3 10
  did -a mp3 02 %mp3.dir
  set %total.mp3s $findfile(%mp3.dir,*.mp3,0)
  if (%total.mp3s == $null) { halt }
  if (%total.mp3s < 1) { halt }
  %inc.mp3 = 1
  %timer.for.list = 5  
  flingfl
}
alias redolist {
  if (%mp3.dir == $null) { halt }
  did -r mp3 02  
  did -r mp3 10
  did -a mp3 02 %mp3.dir
  set %total.mp3s $findfile(%mp3.dir,*.mp3,0)
  if (%total.mp3s == $null) { halt }
  if (%total.mp3s < 1) { halt }
  %inc.mp3 = 1
  %timer.for.list = 5  
  flingfl
}
alias flingfl {
  .timer [ $+ [ %inc.mp3 ] ] -h 1 %timer.for.list did -a mp3 10 $nopath($findfile(%mp3.dir,*.mp3,%inc.mp3))
  .timerabc [ $+ [ %incmp3 ] ] -h 1 %timer.for.list aschet
  halt
}
alias aschet {
  inc %inc.mp3
  if (%inc.mp3 > %total.mp3s) { did -r mp3 30 | did -a mp3 30 %total.mp3s | unset %timer.for.list | halt }
  flingfl
}
alias mp3fwd { 
  if (%type.mp3 == rand) { domp3rand | halt }
  if (%type.mp3 == cont) { domp3cont | halt }
  domp3cont
  halt
}
alias domp3cont {
  set %old.line.mp3.file %cur.file.mp3
  set %current.line $did(mp3,10).sel
  did -c mp3 10 $calc(%current.line + 1) 
  set %cur.file.mp3 $did(mp3,10).seltext
  playmp3
}
alias dobackmp3cont {
  set %current.line $did(mp3,10).sel
  set %shit.this.works $calc(%current.line - 1)
  if (%shit.this.works < 1) { 
    set %current.line $did(mp3,10).lines
    did -c mp3 10 %current.line
    set %cur.file.mp3 $did(mp3,10).seltext
    playmp3
    halt
  }
  did -c mp3 10 %shit.this.works
  set %cur.file.mp3 $did(mp3,10).seltext
  playmp3
  halt
}
alais domp3rand {
  set %old.line.mp3.file %cur.file.mp3
  set %current.line.rand $did(mp3,10).lines
  set %line.to.play $rand(1,%current.line.rand)
  did -c mp3 10 %line.to.play
  set %cur.file.mp3 $did(mp3,10).seltext
  playmp3
}
alias mp3back {
  if (%type.mp3 == rand) { dobackmp3rand | halt }
  if (%type.mp3 == cont) { dobackmp3cont | halt }
  dobackmp3cont
  halt
}
alias dobackmp3rand {
  set %old.line.mp3.file %cur.file.mp3  
  set %cur.file.mp3 %old.line.mp3.file
  playmp3
}
alias delmp3file { did -d mp3 10 $did(mp3,10).sel | halt }
alias addmp3file { did -a mp3 10 $nopath($sfile($mircdir,Select MP3 File)) | halt }
alias addchannels { did -a set 07 $did(set,06) }
alias delchannels { did -r set 07 | remove $mircdirchanlist.txt }
alias setupshit { 
  unset %selchans.mp3.ad
  unset %t.c.t.a
  set %t.c.t.a $did(set,07).lines
  if (%t.c.t.a == 0) { halt }
  set %selchans.mp3.ad $did(set,07,%t.c.t.a).text
  write $mircdirchanlist.txt $did(set,07,%t.c.t.a).text
  :blah
  dec %t.c.t.a
  if (%t.c.t.a == 0) { halt }
  set %selchans.mp3.ad %selchans.mp3.ad $+ , $+ $did(set,07,%t.c.t.a).text
  write $mircdirchanlist.txt $did(set,07,%t.c.t.a).text
  goto blah
}
alias oh.man.i.am.so.tired.right.now.its.4.11.am.and.im.still.dooing.this.after.42.hours.straight {
  set %total.lines.in.this $lines($mircdirchanlist.txt)
  :froghopper
  if (%total.lines.in.this == 0) || (%total.lines.in.this < 0) { halt }
  did -a set 07 $read($mircdirchanlist.txt, %total.lines.in.this)
  dec %total.lines.in.this
  goto froghopper
  halt
}
menu channel { 
  Mp3 PlaYer: dialog -md mp3 mp3 
}